简体   繁体   English

vb.net中的自定义选项卡控件

[英]custom tab controls in vb.net

我想用自定义按钮控制我的标签页...现在我想从标签控件中隐藏我的标签...我该怎么做...

This is possible, the native tab control implemented by Windows sends the TCM_ADJUSTRECT message to allow the client to override the size of the tabs. 这是可能的,由Windows实现的本机选项卡控件发送TCM_ADJUSTRECT消息以允许客户端覆盖选项卡的大小。 Add a new class to your project and paste the code shown below. 将新类添加到您的项目中,然后粘贴以下代码。 Compile. 编译。 Drop the new control from the top of the toolbox onto your form. 将新控件从工具箱的顶部拖放到窗体上。 At design time it still has the tabs so you can easily switch between the pages. 在设计时,它仍然具有选项卡,因此您可以轻松地在页面之间切换。 But they'll be gone at runtime. 但是它们将在运行时消失。

Public Class MyTabControl
  Inherits TabControl

  Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    '--- Hide tabs by trapping the TCM_ADJUSTRECT message
    If m.Msg = &H1328 AndAlso Not DesignMode Then
      m.Result = CType(1, IntPtr)
    Else
      MyBase.WndProc(m)
    End If
  End Sub
End Class

I do not believe you can hide the tab buttons so to solve your problem don't use tab pages at all - instead use the Panel control. 我认为您无法隐藏选项卡按钮,因此要解决您的问题,根本不要使用选项卡页-而是使用Panel控件。

You will be forced to do a little bit more work but you will get the effect you are after. 您将被迫做更多的工作,但是您将获得想要的效果。

To get the same effect as using tabs, use the .visible property to either true or false on each panel. 要获得与使用选项卡相同的效果,请在每个面板.visible属性使用true或false。

Rather than having the pain of laying the panels all out nicely in the designer, design with one panel and then when setting .visible = true , also set the . 在设计器中,您.visible = true将面板全部.visible = true好,而是设计一个面板,然后在设置.visible = true ,还要设置。 top, .left, .width and .height to the values you need. top, .left, .width.height至所需的值。

Hope this makes sense. 希望这是有道理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM