hi,
i'm going to develop a program using VB .NET.
i've bound some textboxes to the same DataSource (DataSet1.Table s(0).
and i enable the user to type the primaryKey of the data in the Table, so if the user has typed an existing PK in the table, the position of the CurrencyManager will be changed. in the 'KeyUp' event of the ID textBox, i implement this code
then i try typing some existing PK in the table and a problem occurs, the data won't change if:
1. i type "2", "3", "4" (any existing PK) then i go back to those i "have visited" like "1" or "2" or "3" the data won't change, but i does change if i type "6" or "7" or "8" (any row that i "haven't visited")
2. i type "9", which is the last data in the Table. than i type any other PK like "7", "8", "1", "5". the data represented won't change.
is there any probelm with my code ?
thanks in advance.
i'm going to develop a program using VB .NET.
i've bound some textboxes to the same DataSource (DataSet1.Table s(0).
and i enable the user to type the primaryKey of the data in the Table, so if the user has typed an existing PK in the table, the position of the CurrencyManager will be changed. in the 'KeyUp' event of the ID textBox, i implement this code
Code:
Private Sub txtID_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtID.KeyUp
If txtID.Text = "" Then Exit Sub
Dim index As Integer
For index = 0 To DataSet1.Tables(0).Rows.Count - 1
If CStr(DataSet1.Tables(0).Rows(index).Item("employeeID")) = txtID.Text Then
CType(BindingContext(DataSet1.Tables(0)), CurrencyManager).Position = index
End If
Next
Debug.WriteLine(CStr(DataSet1.Tables(0).Rows.Count - 1) + " " + txtID.Text)
End Sub
1. i type "2", "3", "4" (any existing PK) then i go back to those i "have visited" like "1" or "2" or "3" the data won't change, but i does change if i type "6" or "7" or "8" (any row that i "haven't visited")
2. i type "9", which is the last data in the Table. than i type any other PK like "7", "8", "1", "5". the data represented won't change.
is there any probelm with my code ?
thanks in advance.
Comment