User (Old forums)MemberNovember 6, 2006 at 6:13 pmPost count: 23064
I need to update my application’s menu when the grid selection changes. The SelectedRowsChanged event would be the obvious choice, but it appears that the event is triggered once for every selected row. If a user selects a hundred rows at once I would like to avoid updating the menu a hundred times. Is there a better way to do this?
Imported from legacy forums. Posted by Lee (had 2952 views)User (Old forums)MemberNovember 9, 2006 at 10:26 amPost count: 23064
You have basically two choices.
First, permit the user to select only one row (GridControl.SelectionMode = SelectionMode.One), which is probably not what you are looking for.
The other suggestion is to use the Application.Idle event, and update the menu in that event according to the rows selected at that moment.
private bool m_selectionChanging;
void gridControl1_SelectedRowsChanged( object sender, EventArgs e )
System.Diagnostics.Debug.WriteLine( “SelectedRowsChanged” );
//first time in SelectedRowsChanged
if( !m_selectionChanging )
m_selectionChanging = true;
Application.Idle += new EventHandler( Application_Idle );
//triggered after the user is done selecting rows
void Application_Idle( object sender, EventArgs e )
Application.Idle -= new EventHandler( Application_Idle );
m_selectionChanging = false;
System.Diagnostics.Debug.WriteLine( “DONE” );
//you would update menu here, using gridControl1.SelectedRows
Imported from legacy forums. Posted by André (had 595 views)User (Old forums)MemberNovember 9, 2006 at 10:52 amPost count: 23064
Very clever! Thanks. I will give that a try.
Imported from legacy forums. Posted by Lee (had 3251 views)User (Old forums)MemberJanuary 9, 2009 at 3:10 pmPost count: 23064
For some reason, the Application.Idle event never fire on my application. My application is a plug-in in another application. So this method won’t work for me.
Is there any other way to prevent multiple times events firing??
Imported from legacy forums. Posted by Leon (had 479 views)User (Old forums)MemberJanuary 13, 2009 at 3:26 pmPost count: 23064
They only solution I can think of is to use the CurrentRowChanged event on GridControl, which is triggered only once when multiple rows are selected at the same time.
Imported from legacy forums. Posted by André (had 776 views)
- You must be logged in to reply to this topic.