G
Guest
Hello,
I have a problem whereby I have a datagrid and and extra field all bound to the same dataset. I can easily edit rows in the dataset by changing the bindingposition in the MyGrid_currentcellchanged event of Mygrid, using the following function
Private Function GetBindingPosition(ByVal IntMatchValue As Integer, ByVal MyMatchField As String, ByVal MyDataTable As DataTable) As Integer
Dim i As Integer = 0
Dim blnValueFnd As Boolean
While (i <= (MyDataTable.Rows.Count - 1)) And Not blnValueFnd
If CType(MyDataTable.Rows(i).Item(MyMatchField), Integer) = IntMatchValue Then
blnValueFnd = True
Return i
Else
i = i + 1
End If
End While
End Function
..This gets the position in the dataset of a keyfield and thus sets the dataset binding position to this value and thus the extra field displays the relevant value.
The problem occurs when I wish to add a row, I can't find the binding position of therow because it does not exist in the dataset yet. If I update it b4 setting the binding position then it uses the previous binding position. The extra field cannot be part of the datagrid because it is too large and looks better kept seperate.
Any ideas would be appreciated.
Geri
I have a problem whereby I have a datagrid and and extra field all bound to the same dataset. I can easily edit rows in the dataset by changing the bindingposition in the MyGrid_currentcellchanged event of Mygrid, using the following function
Private Function GetBindingPosition(ByVal IntMatchValue As Integer, ByVal MyMatchField As String, ByVal MyDataTable As DataTable) As Integer
Dim i As Integer = 0
Dim blnValueFnd As Boolean
While (i <= (MyDataTable.Rows.Count - 1)) And Not blnValueFnd
If CType(MyDataTable.Rows(i).Item(MyMatchField), Integer) = IntMatchValue Then
blnValueFnd = True
Return i
Else
i = i + 1
End If
End While
End Function
..This gets the position in the dataset of a keyfield and thus sets the dataset binding position to this value and thus the extra field displays the relevant value.
The problem occurs when I wish to add a row, I can't find the binding position of therow because it does not exist in the dataset yet. If I update it b4 setting the binding position then it uses the previous binding position. The extra field cannot be part of the datagrid because it is too large and looks better kept seperate.
Any ideas would be appreciated.
Geri