JackW9653
asked on
Move to specific tab page based on user selection from combo box
Hello experts,
I want to direct users to a specific tab page on the same windows form based on their selection from a combo box. For instance if they select "Reschedule" from the drop list I want the tab page with the scheduler to open. I'm using VB.Net 2003.
Thanks,
Jack
I want to direct users to a specific tab page on the same windows form based on their selection from a combo box. For instance if they select "Reschedule" from the drop list I want the tab page with the scheduler to open. I'm using VB.Net 2003.
Thanks,
Jack
ASKER
Hello Fernando, thanks for the quick reply. Is there a way to do this when the tab page text doesn't match the selection? Could I use the index of the tab control page?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works Perfectly! Thanks Fernando.
Jack
Jack
Glad I could help.
Fernando
Fernando
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.ICon
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ComboBox1 As System.Windows.Forms.Combo
Friend WithEvents TabControl1 As System.Windows.Forms.TabCo
Friend WithEvents TabPage1 As System.Windows.Forms.TabPa
Friend WithEvents TabPage2 As System.Windows.Forms.TabPa
Friend WithEvents TabPage3 As System.Windows.Forms.TabPa
<System.Diagnostics.Debugg
Me.ComboBox1 = New System.Windows.Forms.Combo
Me.TabControl1 = New System.Windows.Forms.TabCo
Me.TabPage2 = New System.Windows.Forms.TabPa
Me.TabPage1 = New System.Windows.Forms.TabPa
Me.TabPage3 = New System.Windows.Forms.TabPa
Me.TabControl1.SuspendLayo
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Items.AddRang
Me.ComboBox1.Location = New System.Drawing.Point(88, 216)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(121, 21)
Me.ComboBox1.TabIndex = 0
'
'TabControl1
'
Me.TabControl1.Controls.Ad
Me.TabControl1.Controls.Ad
Me.TabControl1.Controls.Ad
Me.TabControl1.Location = New System.Drawing.Point(8, 8)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedInd
Me.TabControl1.Size = New System.Drawing.Size(272, 184)
Me.TabControl1.TabIndex = 1
'
'TabPage2
'
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(264, 158)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "Function 1"
'
'TabPage1
'
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(264, 158)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "Scheduler"
'
'TabPage3
'
Me.TabPage3.Location = New System.Drawing.Point(4, 22)
Me.TabPage3.Name = "TabPage3"
Me.TabPage3.Size = New System.Drawing.Size(264, 158)
Me.TabPage3.TabIndex = 2
Me.TabPage3.Text = "Function 3"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.TabCont
Me.Controls.Add(Me.ComboBo
Me.Name = "Form1"
Me.Text = "Form1"
Me.TabControl1.ResumeLayou
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ComboBox1_SelectedIndexCha
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexCha
' The text on the tab must match the text in the combo box.
' This way if the order of the tabs are changed this will still
' work.
For Each tp As TabPage In TabControl1.TabPages
If ComboBox1.Text = tp.Text Then
TabControl1.SelectedTab = tp
End If
Next
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 0
End Sub
End Class