TabControl and Sharing Controls on pages

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

I am trying to be able to share a groupbox and its related controls
among all of my tab pages.

This does not error but the controls do not appear either.

Thank you for your help!!



Private Sub TabControl1_TabIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles TabControl1.TabIndexChanged
Dim i As New TabControl.TabPageCollection(Me.TabControl1)
Dim COUNT As Integer
Dim J As Integer
J = TabControl1.SelectedIndex
For COUNT = 0 To i.Count - 1
If
TabControl1.TabPages(COUNT).Controls.Contains(Me.GroupBox1) Then
TabControl1.TabPages(COUNT).Controls.Remove(Me.GroupBox1)
End If
Next
TabControl1.TabPages(J).Controls.Add(Me.GroupBox1)

'do I need to add the location and sizes again as well as it member
controls?
End Sub
 
No that did not work.

I was using the wrong event....

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
Dim i As New TabControl.TabPageCollection(Me.TabControl1)

Dim COUNT As Integer
Dim J As Integer
J = TabControl1.SelectedIndex

For COUNT = 0 To i.Count - 1
If TabControl1.TabPages(COUNT).Controls.Contains(GroupBox1)
Then
TabControl1.TabPages(COUNT).Controls.Remove(GroupBox1)
End If
Next
TabControl1.TabPages(J).Controls.Add(GroupBox1)
End Sub
 
scorpion53061 said:
I am trying to be able to share a groupbox and its related controls among
all of my tab pages.

Place the groupbox outside a tabpage and then move it over the tabcontrol.
Maybe you'll have to choose "Bring to front" to show the groupbox in front
of the tabcontrol.
 
Thats very complicated. A Control can only be in one place at any one time
so theres no need to remove it from the tabpage its on.
You don't need to search the tabpages to find a control that you know the
name of.

\\\
Sub TabControl1_SelectedIndexChanged(...)...
TabControl1.SelectedTab.Controls.Add(GroupBox1)
End Sub
///
 
Back
Top