views:

71

answers:

1

Hopefully simple, but can't find any such option.

I have a data table -- has say... 10 rows in it. Some fields on the form are bound to the table.columns respectively by name.

On another form that HAS a grid, as I scroll the grid, the detail fields are refreshed as expected since the grid does some magic to trigger the DataTable record changing event.

WITHOUT using a Data Grid, How can I direct the table to go to a specific row for load/display refresh on the form... ex:

DataTable MyTable = new DataTable();

MyTable = GetResultsFromSQL();  // returns the 10 rows

MyTable.LoadTheDataForRow(3);
MyTable.LoadTheDataForRow(7);
MyTable.LoadTheDataForRow(2);

I know I can use a foreach row in the table, but need explicit use as I don't want to go through all rows, but need specificity to specific ones.

I've looked at the LoadDataRow(), but that appears to be for pushing data back to a server. NOT what I want... I just want to have the "Current" row of the table to be of a specific one...

Thanks

After further research, I've found that a FORM based control "BindingSource" (or derivative) allows this, such as a grid. But, obviously, there's something the .Net engine is doing under the hood to ultimately "Load" a given row into something that ultimately triggers back to the "BindingSource"... The DataTable has RowChanging and RowChanged events which appear to be triggered by OnRowChanging / OnRowChanged delegates, but how can we tell the data table which "row" we want it as the active one.

The form controls can do this for their binding sources, but what is really happening under the hood to trigger these OnRowChanging events... I don't want to re-load a data table, rows, etc, just change what is considered the "Active" row, as in a grid, listbox, combobox, etc.

+1  A: 

Have you tried:

MyDataTable.Rows[3];
MyDataTable.Rows[7];
MyDataTable.Rows[2];
Chris Ballance
Nope... that comes back as Error 1Only assignment, call, increment, decrement, and new object expressions can be used as a statement
DRapp