C
Chris Dunaway
I am writing a simple Windows Forms Application that accesses an Access
database. In the form I instantiate a DataTable object. I then read the
contents of a single table in the Access file into this DataTable. This
works as expected.
Next, I instantiate another DataTable and use the .Clone method on the
first to duplicate the structure into this new datatable. The user then
type a search value into a textbox. I then search the first datatable and
if the row is found, I copy it to the second datatable. This all works
fine.
Finally, I have a DataGrid on the form which is bound to the *second*
datatable, the one with the found rows. The DataGrid shows the rows that
were found. This part is working.
Now my question(s) (I'll bet you're glad I'm finally getting to the
point!!):
1. If the user adds a row to the second table by mistake, I want them to
be able to highlight it and delete it from the DataGrid as well as from the
second table. The DataGrid is ReadOnly. I can do this if only a single
row is selected, but how to do it if more than one row is selected? The
CurrentRowIndex property only seems to show a single row index regardless
of the number of indices actually selected.
2. Is there any way to turn multi select off on the grid?
3. How can I iterate through the rows of the grid and see which ones are
selected?
Keep in mind that the DataGrid is not bound to the Access database, it is
bound to a table that only has a few rows that were copied from another
table. My aim here is NOT to change the Access database. I am only using
the second DataTable as a tempory collection of rows.
database. In the form I instantiate a DataTable object. I then read the
contents of a single table in the Access file into this DataTable. This
works as expected.
Next, I instantiate another DataTable and use the .Clone method on the
first to duplicate the structure into this new datatable. The user then
type a search value into a textbox. I then search the first datatable and
if the row is found, I copy it to the second datatable. This all works
fine.
Finally, I have a DataGrid on the form which is bound to the *second*
datatable, the one with the found rows. The DataGrid shows the rows that
were found. This part is working.
Now my question(s) (I'll bet you're glad I'm finally getting to the
point!!):
1. If the user adds a row to the second table by mistake, I want them to
be able to highlight it and delete it from the DataGrid as well as from the
second table. The DataGrid is ReadOnly. I can do this if only a single
row is selected, but how to do it if more than one row is selected? The
CurrentRowIndex property only seems to show a single row index regardless
of the number of indices actually selected.
2. Is there any way to turn multi select off on the grid?
3. How can I iterate through the rows of the grid and see which ones are
selected?
Keep in mind that the DataGrid is not bound to the Access database, it is
bound to a table that only has a few rows that were copied from another
table. My aim here is NOT to change the Access database. I am only using
the second DataTable as a tempory collection of rows.