【问题标题】:VB.NET how to change appearance of a panel based on which button is pressed?VB.NET 如何根据按下的按钮更改面板的外观?
【发布时间】:2014-03-17 14:06:47
【问题描述】:

我知道这个问题之前被问过很多次。我的问题类似于show one panel after button is clicked and other panel when second button is clicked in the same frame

我有一个设计师小组。我希望它在单击 button_1 时显示一组控件,并在单击 button_2 时显示另一个控件。我不想通过标签转换器来实现这一点(因为顶部的小标签并不理想)

如何在 Visual Studio 中使用 VB.NET 实现这一点?

【问题讨论】:

    标签: vb.net forms controls


    【解决方案1】:

    您可以使用 .BringToFront() 属性。在 visible 属性中,需要将 other 设置为 false,但如果使用 .BringToFront 属性,则无需将其他控件设置为 visible false。我假设面板是重叠的。

    【讨论】:

      【解决方案2】:

      您写道您不想使用 Tab 控件,因为您不希望选项卡标题可见。然而,Tabcontrol 非常适合这种应用程序。您可以改用此派生控件来隐藏选项卡标题。

      Public Class TablessControl
          Inherits System.Windows.Forms.TabControl
          Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
              ' Hide tabs by trapping the TCM_ADJUSTRECT message
              If (m.Msg = Convert.ToInt32("0x1328", 16) And Not DesignMode) Then
                  m.Result = CType(1, IntPtr)
              Else
                  MyBase.WndProc(m)
              End If
          End Sub
      End Class
      

      免责声明:此代码来自不久前关于 SO 的另一个答案,而不是我的代码。但是效果很好,我会尝试找到相应的答案。 来源:Hide Tab Header on C# TabControl

      将代码放入您的项目并编译一次。然后,您将在工具箱中拥有该控件,并且可以像使用普通选项卡控件一样使用它。在运行时,标题按钮会自动隐藏。

      【讨论】:

        【解决方案3】:

        您可以使用两个Panels(每组控件一个)并在点击Button 时修改它们的.Visible 属性。

        【讨论】:

          猜你喜欢
          • 2021-05-04
          • 2011-01-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-11-13
          • 2010-10-28
          • 1970-01-01
          相关资源
          最近更新 更多