MULTISELECT DATAGRID

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a good way to get an arraylist of all selected rows in a datagrid
without loop through all the rows of its dataview ???
I have a great number of rows shown on the datagrid. For the performance of
the application I think it's no a good idea to loop through all the rows to
test IsSelected (Row) property.

Many thanks
 
Hi..

I think partially you can do this in following way...

in Grid Click event get the HitTestInfo.. this one returns the hti.Row
and hti.Column.


Store this ht.Row in arrayList and get the Primary Key out of this.

Now, from the table do Find on Table with Primary Key so that you can
get the individual row and you don't have to do isSelected from dagarid.

Let me know if you want code snippet then I can provide that also.

Thanks

Silent Ocean...
 
This solution doesn't work as I would like.
I would use the CTRL and the CAPS options to select more than one row at the
same time and the mouse dragging it through the rows of the datagrid
selecting and unselecting the rows.
Then I would like to get all the rows selected...
 
NQ said:
This solution doesn't work as I would like.
I would use the CTRL and the CAPS options to select more than one row at the
same time and the mouse dragging it through the rows of the datagrid
selecting and unselecting the rows.
Then I would like to get all the rows selected...
I dont understand what do you mean by dragging, but as I understand when
you press the CTRL button, you can catch which button was pressed in
KeyUp or KeyDow or MouseUp event. Store first hti.Row in temperory
variable and check in those events if CTRL is pressed with left mouse
button click , if yes then select all the rows which are between first
hti.Row and second hti.Row.

by datagrid.select[hti.Row,hti.Column] get the primary key values of the
rows and do DataTable.Find and get the individual rows. And pass that
row collection to some other form...


As I understand you want to do multiple select as we do in Excel by
pressing SHIFT button
 
ok
I reached the result
Many thanks...

Deep Silent Ocean said:
NQ said:
This solution doesn't work as I would like.
I would use the CTRL and the CAPS options to select more than one row at the
same time and the mouse dragging it through the rows of the datagrid
selecting and unselecting the rows.
Then I would like to get all the rows selected...
I dont understand what do you mean by dragging, but as I understand when
you press the CTRL button, you can catch which button was pressed in
KeyUp or KeyDow or MouseUp event. Store first hti.Row in temperory
variable and check in those events if CTRL is pressed with left mouse
button click , if yes then select all the rows which are between first
hti.Row and second hti.Row.

by datagrid.select[hti.Row,hti.Column] get the primary key values of the
rows and do DataTable.Find and get the individual rows. And pass that
row collection to some other form...


As I understand you want to do multiple select as we do in Excel by
pressing SHIFT button
 
Back
Top