How to move a row pointer in a datatable??

atblasi

New member
Joined
May 16, 2008
Messages
1
Programming Experience
10+
How do I move a row pointer in a datatable??

Hi,


I need to set a datatable to a certain row. I am doing a search using the find command on my datatable. The find command returns a datarow and is working fine. I then need to move the datatable row pointer to the returned row but don’t know how. I am using the binding navigator in my form to navigate the datatable. How can I move the row pointer to the returned data row?

Thank you
Aaron
 
Last edited:
There's no such thing as a row pointer in a DataTable. A DataTable just sits there containing data. It doesn't have any concept of a current row.

It's the BindingSource that does have a current item. The item itself is returned via the Current property and its index is accessed via the Position property. You should not be using the DataTable's Find method at all. You should be calling the Find method of the BindingSource and then using the result to set its Position property.
 
Last edited:
It's the BindingNavigator that does have a current item. The item itself is returned via the Current property and its index is accessed via the Position property. You should not be using the DataTable's Find method at all. You should be calling the Find method of the BindingSource and then using the result to set its Position property.

To further jmc's post:

A BindingNavigator is more like a glorified ToolStrip that simply shows the .Position of the BindingSource it is linked to. It also has some methods that change the .Position, but in itself, the nav doesnt store or point to any rows. Think of it like a viewer/controller to a BindingSource (if we are talking MVC style architecture)

We can have a BindingSource without a BindingNavigator, so BS is the useful item that functions as a "row pointer", whereas BN is somewhere between semi-useful and useless because all it really does is show and move the pointer implemented by something else

Ultimately I must stress his ultimate point (in bold) as the correct way to achieve your goal
 

Latest posts

Back
Top