Wrox Home  
Search P2P Archive for: Go

  Return to Index  

dotnet_windows_app_design thread: Re: Windows tabcontrol


Message #1 by ccooper@b... on Wed, 8 Jan 2003 16:17:45
Rob,

I would do it this way :

Private currentTABIndex As Integer = 0
Private selectingTREE As Boolean

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e 
As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        
        Select Case e.Node.Text
            Case "TAB 1"
                Me.selectingTREE = True
                Me.TabControl1.SelectedTab = Me.TabPage1
                Me.currentTABIndex = Me.TabControl1.SelectedIndex
            Case "TAB 2"
                Me.selectingTREE = True
                Me.TabControl1.SelectedTab = Me.TabPage2
                Me.currentTABIndex = Me.TabControl1.SelectedIndex
            Case "TAB 3"
                Me.selectingTREE = True
                Me.TabControl1.SelectedTab = Me.TabPage3
                Me.currentTABIndex = Me.TabControl1.SelectedIndex
            Case "TAB 4"
                Me.selectingTREE = True
                Me.TabControl1.SelectedTab = Me.TabPage4
                Me.currentTABIndex = Me.TabControl1.SelectedIndex
        End Select
    End Sub

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal 
e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        
        If Not Me.TabControl1.SelectedIndex.Equals(currentTABIndex) And 
Me.selectingTREE = False Then
            MessageBox.Show("Please select options from the tree, not the 
tabs.")
            Try
                Me.TabControl1.SelectedIndex = Me.currentTABIndex
            Catch
                'Handles invalid currentTABIndex 
            End Try
        Else
            Me.selectingTREE = False
        End If
    End Sub

> HI All

> I'm trying to stop users from bieng able to change the active tabpage in 
a 
w> indows tabcontrol. I've got a treeview on the left hand half of my 
form, 
a> nd depending which node the user chooses will decide which tabpage is 
e> xposed. That bit I've figured out.

> But more importantly, I don't want the users to be able to choose the 
t> abpage themselves.

> HAs anyone got any ideas? 

> Regards

> Rob Webb.

  Return to Index