【问题标题】:How To Switch Focus To A Different Tab Using DevExpress' DockPanel and DocumentManager如何使用 DevExpress 的 DockPanel 和 DocumentManager 将焦点切换到不同的选项卡
【发布时间】:2019-06-17 22:15:55
【问题描述】:

我有一个 DocumentManager DocumentManager1(我在 WinForms 设计器中放置了一个停靠面板 dockPanel1。我停靠了 dockPanel1 以便它已完全停靠。它看起来像一个带有“空”标题的选项卡。

我有另一个停靠面板 dockPanel2,我以编程方式添加:

dockPanelCaption = "New";

var dockPanel2 = new DockPanel
{
   Text = dockPanelCaption,
   Name = dockPanelCaption,
   Tag = dockPanelCaption,         
};

documentManager1.View.AddDocument(dockPanel2);

这会产生一个如下所示的 GUI(我圈出了我使用上面的代码添加的新停靠面板):

我只想以编程方式将焦点切换到新的“选项卡”(即停靠面板)。承认我已经投入了数小时试图做到这一点,我感到很愚蠢——首先我自己进行试验,然后搜索 DevExpress 文章。这里什么不起作用:

  • dockPanel2.Focus();
  • documentManager1.View.ActivateDocument(dockPanel2);

我也尝试了 TabbedView 对象,但无济于事。

有什么想法吗?

【问题讨论】:

    标签: devexpress devexpress-windows-ui


    【解决方案1】:

    试试这个:

    documentManager1.View.Controller.ActivateDocument(dockPanel2);
    

    或:

    documentManager1.ActivePanel = dockPanel2;
    

    【讨论】:

    • 我已经离开了代码,将外出旅行。但我会验证您的答案并很快再次发布。谢谢。
    猜你喜欢
    • 2016-04-15
    • 1970-01-01
    • 2015-12-21
    • 1970-01-01
    • 1970-01-01
    • 2019-09-02
    • 1970-01-01
    • 2016-11-14
    相关资源
    最近更新 更多