[VB.Net] Basic Custom Tab (Minimal code required) 05-06-2011, 02:40 PM
#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:
Note: If you want to use PictureBoxes then edit the Subroutine TabClicked accordingly.
Have a nice day.
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
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 SubHave a nice day.
![[Image: rytwG00.png]](http://i.imgur.com/rytwG00.png)
Redcat Revolution!





![[+]](https://sinister.li/images/modern/collapse_collapsed.png)