I've got a little problem i haven't being able to solve.
see screenhot here http://justanotherhomepage.net/3rowsselected.jpg
I use this sub to browse thru the selected rows of the datagrid
the console.write outoput isVB Code:
Dim lista As New ArrayList lista = GetSelectedRows(Me.DataGrid2) For i = 0 To lista.Count - 1 ind = Convert.ToInt32(lista(i)) Me.DataGrid2.Select(ind) genc = Me.DataGrid2.Item(Me.DataGrid2.CurrentRowIndex, 0).ToString gposenc = Convert.ToInt32(Me.DataGrid2.Item(Me.DataGrid2.CurrentRowIndex, 1)) Console.WriteLine("index=" & ind.ToString) Console.WriteLine("enc=" & genc) Console.WriteLine("posenc=" & gposenc.ToString) Next
index=34
enc=741/99
posenc=5
index=36
enc=741/99
posenc=5
index=38
enc=741/99
posenc=5
It should be
index=34
enc=741/99
posenc=1
index=36
enc=741/99
posenc=3
index=38
enc=741/99
posenc=5
RegardsVB Code:
Private Function GetSelectedRows(ByVal dg As DataGrid) As System.Collections.ArrayList Dim al As New ArrayList Dim cm As CurrencyManager = DirectCast(Me.BindingContext(dg.DataSource, dg.DataMember), CurrencyManager) Dim dv As DataView = CType(cm.List, DataView) Dim i As Integer For i = 0 To dv.Count - 1 If dg.IsSelected(i) Then al.Add(i) End If Next Return al End Function 'GetSelectedRows
Jorge


Reply With Quote
