how to locate the selected item in the datagrid

  • Thread starter Thread starter zbcong
  • Start date Start date
Z

zbcong

hello
when a line in the datagrid is selected,how can i know in the program whick
line is selected(just like that the listview can return the
"selecteditems",but datagrid can't)?

thank you!!
 
hi,

to check if a specific row is selected use the datagrid's "IsSelected"
method. If you want to get all selected rows, you have to loop through all
rows and remember each selected row's index.

Regards,
Stephan
 
Don't you just love inheritance?
this sample inherits from DataGrid and then returns an IList of
SelectedItems.

HTH

Pieter
 
Back
Top