Sinisterly
[VB.Net] Basic Custom Tab (Minimal code required) - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework)
+--- Thread: [VB.Net] Basic Custom Tab (Minimal code required) (/Thread-VB-Net-Basic-Custom-Tab-Minimal-code-required)



[VB.Net] Basic Custom Tab (Minimal code required) - Coder-san - 05-06-2011

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


RE: [VB.Net] Basic Custom Tab (Minimal code required) - 1234hotmaster - 05-06-2011

thanks man i was looking for this high and low :thumbs:


RE: [VB.Net] Basic Custom Tab (Minimal code required) - Coder-san - 05-06-2011

Remember to change Me.Controls to YourContainer.Controls Smile