【问题标题】:How to Hide/Show UserControls for DevExpress windows Application如何隐藏/显示 DevExpress windows 应用程序的用户控件
【发布时间】:2013-06-01 06:10:11
【问题描述】:

您好,我正在使用 DevExpress WinForms 控件创建 Windows 应用程序。

我创建了主页,其中包含顶部的 RibbonControl 和左侧的导航栏和充当所有用户控件容器的大面板,例如 MainPanel。

当我单击导航栏中的任何项目时,用户控件将添加到 MainPanel。 它工作正常。

但是当我想从一个用户控件移动到另一个用户控件时, - 如何访问 MainPanel 和 - 如何显示另一个用户控件并隐藏当前用户控件。

在面板中添加 UserControl 的代码:

mainPanel.Controls.Clear();
 CustomerListControl c1 = new CustomerListControl();
 c1.Dock = DockStyle.Fill;
 mainPanel.Controls.Add(c1);

请帮忙!!

【问题讨论】:

  • 请发布更多代码以显示来自 DevExpress 的类。另外,当你上面的代码被执行时会发生什么?是新的 UC 没有出现还是怎么回事?

标签: c# .net user-controls devexpress devexpress-windows-ui


【解决方案1】:

我在我的代码中使用了 Grid 作为主面板,对我来说效果很好,

GridMain.Children.Clear();
CustomerListControl1 c1 = new CustomerListControl1();
CustomerListControl2 c2 = new CustomerListControl2();
GridMain.Childern.Add(c1); //if you use grid
GridMain.Children.Add(c2); //if you use a grid
GridMain.Children[0].Visibility = Visibility.Collapsed;
GridMain.Children[1].Visibility = Visibility.Collapsed;
GridMain.InvalidateVisual();

现在如果你想显示 c1 调用

GridMain.Children[0].Visibility = Visibility.Visible;
GridMain.Children[1].Visibility = Visibility.Collapsed;

如果你想让 c2 可见,调用

GridMain.Children[0].Visibility = Visibility.Collapsed;
GridMain.Children[1].Visibility = Visibility.Visible;

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-03
    • 2011-01-09
    • 1970-01-01
    • 2011-12-24
    • 2021-08-22
    • 2015-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多