Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab Index problem with custom controls

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
Im not sure how to explain this so im gonna describe what ive done and the tab problem that is occouring.

First I created a custom control(control1) that has a textbox on it and a label under the textbox. The label is not a tabstop the textbox is. Now if i use this control(control1) on a form it works just fine there is no problem. The problem occours when I create another control(control2) that has 3 control 1's on it and 6 textboxes on it (arranged similar to a datagrid one control1 followed by two textboxes, then down below that row would be the same arrangement) so that the tab order is 1.) control1-1 2.)textbox1-1 3.)textbox2-1 4.)control1-2 5.)textbox1-2 6.)textbox 2-2 7.)control1-3 8.)textbox1-3 9.)textbox2-3. Now if i put this new control(control2) on a form and if i click into any of the control1's and press tab it will go to the next tabstop as if i hadnt clicked the control1 at all. Here is an example to maybe help describe the problem, I run the app, click onto control1-2(tabstop 4) and press tab it will tab to textbox 1-1(tabstop 2) even though the next tab should be textbox1-2(tabstop 5). Now click back into control 1-2(tabstop 4) and press tab again and it will tab to textbox2-1(tabstop 3) when again it should have tabbed to textbox 1-2(tabstop 5). It will continue to do this tabbing through each control.

So if anyone has experianced this problem or knows how to fix it i would greatly appreciate it. I know my description is a little confusing but it takes about 3 minutes to recreate my project so if you want you could do that to better see what im talkign about.

Thanks again
 
Sure

Code for Control1

Public Class Control1
Inherits System.Windows.Forms.UserControl

#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

'UserControl 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.IContainer

'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 TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 16)
Me.TextBox1.Name = &quot;TextBox1&quot;
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = &quot;TextBox1&quot;
'
'Control1
'
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1})
Me.Name = &quot;Control1&quot;
Me.Size = New System.Drawing.Size(136, 56)
Me.ResumeLayout(False)

End Sub

#End Region

End Class
 
Code for control 2


Public Class Control2
Inherits System.Windows.Forms.UserControl

#Region &quot; Windows Form Designer generated code &quot;

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl 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.IContainer

'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 Control11 As IMAS.Control1
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Control12 As IMAS.Control1
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Control13 As IMAS.Control1
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Control11 = New IMAS.Control1()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.Control12 = New IMAS.Control1()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.Control13 = New IMAS.Control1()
Me.TextBox5 = New System.Windows.Forms.TextBox()
Me.TextBox6 = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'Control11
'
Me.Control11.Location = New System.Drawing.Point(48, 32)
Me.Control11.Name = &quot;Control11&quot;
Me.Control11.Size = New System.Drawing.Size(136, 56)
Me.Control11.TabIndex = 0
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(248, 48)
Me.TextBox1.Name = &quot;TextBox1&quot;
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = &quot;TextBox1&quot;
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(408, 48)
Me.TextBox2.Name = &quot;TextBox2&quot;
Me.TextBox2.Size = New System.Drawing.Size(96, 22)
Me.TextBox2.TabIndex = 2
Me.TextBox2.Text = &quot;TextBox2&quot;
'
'Control12
'
Me.Control12.Location = New System.Drawing.Point(48, 104)
Me.Control12.Name = &quot;Control12&quot;
Me.Control12.Size = New System.Drawing.Size(136, 56)
Me.Control12.TabIndex = 3
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(248, 120)
Me.TextBox3.Name = &quot;TextBox3&quot;
Me.TextBox3.TabIndex = 4
Me.TextBox3.Text = &quot;TextBox3&quot;
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(416, 120)
Me.TextBox4.Name = &quot;TextBox4&quot;
Me.TextBox4.TabIndex = 5
Me.TextBox4.Text = &quot;TextBox4&quot;
'
'Control13
'
Me.Control13.Location = New System.Drawing.Point(48, 184)
Me.Control13.Name = &quot;Control13&quot;
Me.Control13.Size = New System.Drawing.Size(136, 56)
Me.Control13.TabIndex = 6
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(248, 200)
Me.TextBox5.Name = &quot;TextBox5&quot;
Me.TextBox5.TabIndex = 7
Me.TextBox5.Text = &quot;TextBox5&quot;
'
'TextBox6
'
Me.TextBox6.Location = New System.Drawing.Point(416, 200)
Me.TextBox6.Name = &quot;TextBox6&quot;
Me.TextBox6.TabIndex = 8
Me.TextBox6.Text = &quot;TextBox6&quot;
'
'Control2
'
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox6, Me.TextBox5, Me.Control13, Me.TextBox4, Me.TextBox3, Me.Control12, Me.TextBox2, Me.TextBox1, Me.Control11})
Me.Name = &quot;Control2&quot;
Me.Size = New System.Drawing.Size(560, 272)
Me.ResumeLayout(False)

End Sub

#End Region

End Class
 
Code for the form


Public Class Form1
Inherits System.Windows.Forms.Form

#Region &quot; Windows Form Designer generated code &quot;

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.IContainer

'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 Control21 As IMAS.Control2
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Control21 = New IMAS.Control2()
Me.SuspendLayout()
'
'Control21
'
Me.Control21.Location = New System.Drawing.Point(88, 72)
Me.Control21.Name = &quot;Control21&quot;
Me.Control21.Size = New System.Drawing.Size(560, 272)
Me.Control21.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
Me.ClientSize = New System.Drawing.Size(768, 416)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Control21})
Me.Name = &quot;Form1&quot;
Me.Text = &quot;Form1&quot;
Me.ResumeLayout(False)

End Sub

#End Region

End Class
 
ttt, I am going to try to duplicate the problem on another machine. Any idea why this is happening?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top