Using Binding manager to retrieve several clicked rows

  • Thread starter Thread starter VMI
  • Start date Start date
V

VMI

I'm using Binding Manager to retrieve the current table row that the user
clicked on (one highlighted row). But if I want to retrieve all the
highlighted rows, how can I do it?
This is the code to retrieve one row:
DataRowView rowViewAudit = (DataRowView)
((CurrencyManager)BindingContext[_table_auditAddress]).Current;

Now I want to modify this line so it retrieves all the highlighted rows. Is
it possible?

Thanks.
 
I might be wrong but I don't believe there's support for that. It wouldn't be
hard to just use a foreach selected item and pull directly from table.
 
Thanks for the post.
How can I use Binding Manager to go through the grid in order to find the
highlighted rows?


Alex K said:
I might be wrong but I don't believe there's support for that. It wouldn't be
hard to just use a foreach selected item and pull directly from table.

VMI said:
I'm using Binding Manager to retrieve the current table row that the user
clicked on (one highlighted row). But if I want to retrieve all the
highlighted rows, how can I do it?
This is the code to retrieve one row:
DataRowView rowViewAudit = (DataRowView)
((CurrencyManager)BindingContext[_table_auditAddress]).Current;

Now I want to modify this line so it retrieves all the highlighted rows. Is
it possible?

Thanks.
 
Like this:

public ArrayList GetSelectedRows(DataGrid dg)
{
ArrayList al = new ArrayList();
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dg.DataSource, dg.DataMember];
DataView dv = (DataView)cm.List;

for(int i = 0; i < dv.Count; ++i)
{
if(dg.IsSelected(i))
al.Add(i);
}
return al;
}

VMI said:
Thanks for the post.
How can I use Binding Manager to go through the grid in order to find the
highlighted rows?


Alex K said:
I might be wrong but I don't believe there's support for that. It wouldn't be
hard to just use a foreach selected item and pull directly from table.

VMI said:
I'm using Binding Manager to retrieve the current table row that the user
clicked on (one highlighted row). But if I want to retrieve all the
highlighted rows, how can I do it?
This is the code to retrieve one row:
DataRowView rowViewAudit = (DataRowView)
((CurrencyManager)BindingContext[_table_auditAddress]).Current;

Now I want to modify this line so it retrieves all the highlighted rows. Is
it possible?

Thanks.
 
Back
Top