Login Register






[VB.Net] Basic Custom Tab (Minimal code required) filter_list
Author
Message
[VB.Net] Basic Custom Tab (Minimal code required) #1
Basic Custom Tab (Minimal code required)

We know there is no Index property now in VB.Net, but there are workarounds.
In this little subroutine I am using the Tag property of a control to show Panels like Tabs.

You will need:
  • Buttons
  • Panels
For this code to work correctly, it is required to add Text like "Tab1, Tab2, etc" in Tag properties of buttons/pictureboxes and Panels in Design-time.
Note: If you want to use PictureBoxes then edit the Subroutine TabClicked accordingly.

Code:
Private Sub TabClicked(ByVal TabButton As Button) For Each ctrl As Control In Me.Controls If TypeOf (ctrl) Is Button Then ctrl.Font = New Font(ctrl.Font.Name, ctrl.Font.Size, FontStyle.Regular) End If If TypeOf (ctrl) Is Panel Then If ctrl.Tag = TabButton.Tag Then ctrl.Visible = True TabButton.Font = New Font(TabButton.Font.Name, TabButton.Font.Size, FontStyle.Bold) Else If ctrl.Tag.ToString.Contains("Tab") = True Then ctrl.Visible = False End If End If Next End Sub 'Usage: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TabClicked(Button1) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TabClicked(Button2) End Sub

Have a nice day. Smile
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [VB.Net] Basic Custom Tab (Minimal code required) #2
thanks man i was looking for this high and low :thumbs:
Pierce the life fibers with your drill.

Reply

RE: [VB.Net] Basic Custom Tab (Minimal code required) #3
Remember to change Me.Controls to YourContainer.Controls Smile
[Image: rytwG00.png]
Redcat Revolution!

Reply