VBeginner
VBeginner

Reputation: 1

Tab Control Troubles

Best to explain with an example.

TabControl has Tab1 and Tab2.

I'm trying to make it so when Tab1 is selected, Button1 is visible and stays visible. When Tab2 is selected, Button1 is invisible and stays invisible. I need it to work when the Tab is clicked, not when the content area of the Tab is clicked.

Thank you.

Upvotes: 0

Views: 123

Answers (2)

Tim Schmelter
Tim Schmelter

Reputation: 460370

Try this:

Private Sub TabControl1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseClick
        Me.Button1.Visible = TabControl1.SelectedTab Is TabPage1
        Me.Button2.Visible = TabControl1.SelectedTab Is TabPage2
End Sub

Btw, why do you need that? If Button1 is on TabPage 1 and Button2 is on TabPage2 they will appear/hide automatically.

Regards

Upvotes: 1

Avitus
Avitus

Reputation: 15978

One way you can do that is to add an "onclickclick" function to each tab head that sets the visibility style of the buttons you're trying to show / hide.

Upvotes: 0

Related Questions