Moving through a DataGrid in VB.Net 2003

  • Thread starter Thread starter Atley
  • Start date Start date
A

Atley

I am trying to move through a DataGrid to compare the first letter in the
first column to enable a quick scroll-down method to the correct record in a
large dataset using the input panel. In eVB, VB, etc this was fairly
straight-forward... Now it is not.

Has anyone here come up with an effective way to move through the data on a
DataGrid one row at a time... I have looked and looked and I just am not
seeing it.


Any help is greatly appreciated.

Atley
 
It depends on what type of collection the grid is bound to, one solution
would be to use a foreach loop on the items in the collection (while
maintaining the index position) and check your first property, then use the
index of the first matching row to select the row in the grid. Alternatively
if you are using a DataTable you can use the Select method to apply some
criteria and then determine the first matching record.

Peter
 
Peter Foot said:
It depends on what type of collection the grid is bound to, one solution
would be to use a foreach loop on the items in the collection (while
maintaining the index position) and check your first property, then use the
index of the first matching row to select the row in the grid. Alternatively
if you are using a DataTable you can use the Select method to apply some
criteria and then determine the first matching record.
I would even say Find - on the DefaultDataView
 
Do you know of any examples of either of these methods? It is just easier
for me to get the concept if I see something similar, it doesn't even have
to be the exact same method...

When you say items in the collection, do you mean the collection of rows in
the grid, and if so how do I access that... I need to be able to find out
how many rows in the datagrid. if I can get that, then i can at least do a
fornext loop that can move to each row...

As for the Select Method,

Also, my concern with using the datatable concept, is that I have to
instanciate a new datatable. Once I have done that and found the record
that I want, how does that translate to the datagrid that I actually want to
move the cursor in?
 
Is DefaultDataView on the DataTable or the Grid? Will it affect the
contents of the grid? I just want to move to the appropriate record in the
DataGrid.
 
Thanks that helped a lot... I ended up modifying that slightly to allow me
to scroll through different records that start with the same letter.

Atley
 
Back
Top