Active record in a datagrid

  • Thread starter Thread starter JJ
  • Start date Start date
J

JJ

Hi All,

when I have a datagrid bound to a dataview, how
can I tell in code wihich is the active record so that
I can use it for other things. That is to say, how
can I get the current record number based on the
currently active row in a datagrid?

Any help or advise on where to look to solve this
question would be most appreciated.

Thanks,

Jason.
 
You can walk through the grid and test for each row's IsSelected property to
be true. If so, that index will correspond to the index in the dataView.

HTH,

Bill
 
William,

I have solved the problem by checking the

datagrid.currentrowindex

property. It seems to work fine. Do you have any more
information on using the IsSelected property of the
datarid's row property?

Thanks,

Jason.
 
What were you looking for?
JJ said:
William,

I have solved the problem by checking the

datagrid.currentrowindex

property. It seems to work fine. Do you have any more
information on using the IsSelected property of the
datarid's row property?

Thanks,

Jason.
 
You suggested that I could determine the current record that
was selected in the datagrid by checking the IsSelected
property of the row. I was wondering if you had any sample
code that did this as it was not the technique that I used
to solve the problem and I wan't to evaluate them both for
future use..

Thanks,

Jason.
 
For z As Integer = 0 To GridSource.Count - 1
If dg.IsSelected(z) Then
'DoSomething
End If
Next
Where gridSource is a DataView that the grid is bound to. The same would
work using DataTable.ROws.Count-1
 
Back
Top