How to select Tab Control tab page programmatically? 
Author Message
 How to select Tab Control tab page programmatically?

I have two tab controls (tabIndex and tabData).  I would like to click a tab
on tabIndex and then select a tab on tabData thru code.  The following code
gives you the idea, it runs, but does not bring the tabData tab forward:
Private Sub tabIndex_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tabIndex.SelectedIndexChanged

If tabIndex.SelectedTab.TabIndex = pgChart.TabIndex Then

tabData.SelectedTab.TabIndex = pgCharts.TabIndex

tabData.SelectedTab.BringToFront()    'does nothing

End If

End Sub

How should this be coded?

Thanks,

Dean



Sat, 14 May 2005 12:46:20 GMT  
 How to select Tab Control tab page programmatically?
Hi Dean,

That code loosk a bit strange to me. TabIndex is meant to be the order in which
controls are navigated to.  Changing that property won't change the active
tabpage.

What you probably want to do is :

idx = index of the page to show

tabData.SelectedIndex = idx


Quote:
> I have two tab controls (tabIndex and tabData).  I would like to click a tab
> on tabIndex and then select a tab on tabData thru code.  The following code
> gives you the idea, it runs, but does not bring the tabData tab forward:
> Private Sub tabIndex_SelectedIndexChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles tabIndex.SelectedIndexChanged

> If tabIndex.SelectedTab.TabIndex = pgChart.TabIndex Then

> tabData.SelectedTab.TabIndex = pgCharts.TabIndex

> tabData.SelectedTab.BringToFront()    'does nothing

> End If

> End Sub

> How should this be coded?

> Thanks,

> Dean



Sat, 14 May 2005 13:21:00 GMT  
 How to select Tab Control tab page programmatically?
Thanks, Bill.  The final working code looks like this:
Private Sub tabTree_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles tabTree.SelectedIndexChanged

If tabTree.SelectedIndex = tabTree.TabPages.IndexOf(pgChart) Then

tabData.SelectedIndex = tabData.TabPages.IndexOf(pgCharts)

End If

End Sub


Quote:
> Hi Dean,

> That code loosk a bit strange to me. TabIndex is meant to be the order in
which
> controls are navigated to.  Changing that property won't change the active
> tabpage.

> What you probably want to do is :

> idx = index of the page to show

> tabData.SelectedIndex = idx



> > I have two tab controls (tabIndex and tabData).  I would like to click a
tab
> > on tabIndex and then select a tab on tabData thru code.  The following
code
> > gives you the idea, it runs, but does not bring the tabData tab forward:
> > Private Sub tabIndex_SelectedIndexChanged(ByVal sender As Object, ByVal
e As
> > System.EventArgs) Handles tabIndex.SelectedIndexChanged

> > If tabIndex.SelectedTab.TabIndex = pgChart.TabIndex Then

> > tabData.SelectedTab.TabIndex = pgCharts.TabIndex

> > tabData.SelectedTab.BringToFront()    'does nothing

> > End If

> > End Sub

> > How should this be coded?

> > Thanks,

> > Dean



Sun, 15 May 2005 11:21:33 GMT  
 How to select Tab Control tab page programmatically?
Thanks Dean


Quote:
> Thanks, Bill.  The final working code looks like this:
> Private Sub tabTree_SelectedIndexChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles tabTree.SelectedIndexChanged

> If tabTree.SelectedIndex = tabTree.TabPages.IndexOf(pgChart) Then

> tabData.SelectedIndex = tabData.TabPages.IndexOf(pgCharts)

> End If

> End Sub



> > Hi Dean,

> > That code loosk a bit strange to me. TabIndex is meant to be the order in
> which
> > controls are navigated to.  Changing that property won't change the active
> > tabpage.

> > What you probably want to do is :

> > idx = index of the page to show

> > tabData.SelectedIndex = idx



> > > I have two tab controls (tabIndex and tabData).  I would like to click a
> tab
> > > on tabIndex and then select a tab on tabData thru code.  The following
> code
> > > gives you the idea, it runs, but does not bring the tabData tab forward:
> > > Private Sub tabIndex_SelectedIndexChanged(ByVal sender As Object, ByVal
> e As
> > > System.EventArgs) Handles tabIndex.SelectedIndexChanged

> > > If tabIndex.SelectedTab.TabIndex = pgChart.TabIndex Then

> > > tabData.SelectedTab.TabIndex = pgCharts.TabIndex

> > > tabData.SelectedTab.BringToFront()    'does nothing

> > > End If

> > > End Sub

> > > How should this be coded?

> > > Thanks,

> > > Dean



Sun, 15 May 2005 15:28:48 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Masked Edit COM control appears only on first tab page of tab control in VB.NET

2. How to change order of tab page programmatically?

3. Selecting tab on tab strip

4. Newbie: How to select a tab on a tab strip

5. changing color of tab header of tab pages

6. Prevent multiline tabs from moving up and down on a tab page

7. tab bars do not match tab page

8. Tabbing through controls on a tab control

9. tab control - loading controls onto tabs in runtime

10. Tab control & Control on a tab

11. How to set the current tab in Tab control of MS COMMON CONTROL

12. Special Tab Control similar to tab control in MS outlook

 

 
Powered by phpBB® Forum Software