Text is getting typed into another text box
-
I need help with the following code. I am building a custom control. I am storing controls in arrays as I need more rows. When I type into the second text box as soon as i run the program the text is typed into the first text box. Please help. I thank you in advance. Imports System.Drawing Imports System.Windows.Forms Public Class UserControl1 Dim arrText1(1), arrtext2(1) As TextBox Public Sub SetTextBoxes() Dim text1 As New TextBox() With text1 .Name = "text1" .Left = 8 .Font = New Font(.Font.Name, 14, FontStyle.Regular, .Font.Unit) .Size = New Point(80, 30) Me.Controls.Add(text1) arrText1(0) = text1 End With Dim text2 As New TextBox() With text2 .Name = "text2" .Left = 100 .Font = New Font(.Font.Name, 14, FontStyle.Regular, .Font.Unit) .Size = New Point(80, 30) Me.Controls.Add(text2) arrtext2(0) = text2 End With End Sub Private Sub ucGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SetTextBoxes() End Sub End Class :confused:
-
I need help with the following code. I am building a custom control. I am storing controls in arrays as I need more rows. When I type into the second text box as soon as i run the program the text is typed into the first text box. Please help. I thank you in advance. Imports System.Drawing Imports System.Windows.Forms Public Class UserControl1 Dim arrText1(1), arrtext2(1) As TextBox Public Sub SetTextBoxes() Dim text1 As New TextBox() With text1 .Name = "text1" .Left = 8 .Font = New Font(.Font.Name, 14, FontStyle.Regular, .Font.Unit) .Size = New Point(80, 30) Me.Controls.Add(text1) arrText1(0) = text1 End With Dim text2 As New TextBox() With text2 .Name = "text2" .Left = 100 .Font = New Font(.Font.Name, 14, FontStyle.Regular, .Font.Unit) .Size = New Point(80, 30) Me.Controls.Add(text2) arrtext2(0) = text2 End With End Sub Private Sub ucGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SetTextBoxes() End Sub End Class :confused:
The code you posted here appears to work just fine. Whatever is causing the problem must be somewhere else. What are the arrays for?
My advice is free, and you may get what you paid for.
-
The code you posted here appears to work just fine. Whatever is causing the problem must be somewhere else. What are the arrays for?
My advice is free, and you may get what you paid for.
Thanks for the fast reply. It happens only the first time you run the code and type into the second text box. Otherwise it works fine. I am using the arrays in order to have more rows in my control (sort of control array of vb6). This code works fine with my regular windows form in vb.net 2008. But it does not work in my user control form in vb.net 2008. Please help.
modified on Monday, May 18, 2009 7:48 AM
-
Thanks for the fast reply. It happens only the first time you run the code and type into the second text box. Otherwise it works fine. I am using the arrays in order to have more rows in my control (sort of control array of vb6). This code works fine with my regular windows form in vb.net 2008. But it does not work in my user control form in vb.net 2008. Please help.
modified on Monday, May 18, 2009 7:48 AM
So apparently the error is caused by some difference between the standard windows form and your user control form. I suppose you'll need to check what differences there are between the two.
My advice is free, and you may get what you paid for.
-
So apparently the error is caused by some difference between the standard windows form and your user control form. I suppose you'll need to check what differences there are between the two.
My advice is free, and you may get what you paid for.
-
Hi Johan, this is for your information. I have placed two text boxes in the user control (Design time) without any coding. Still the text i type in the second text box is getting typed in the first text box and the cursor in the second text box is moving as per the characters typed (giving out blank spaces in the first text box). Any idea what the problem could be. Do you think i should reinstall vb.net ?!