Home Forums WinForms controls Xceed Grid for WinForms GridControl SelectedRowsChanged

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14876 |

    Hi,

    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?

    Lee

    Imported from legacy forums. Posted by Lee (had 2952 views)

    User (Old forums)
    Member
    Post 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.

    i.e.:

    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)
    Member
    Post count: 23064

    Very clever! Thanks. I will give that a try.

    Lee

    Imported from legacy forums. Posted by Lee (had 3251 views)

    User (Old forums)
    Member
    Post 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?? 

     

    thanks.

     

    Leon 

    Imported from legacy forums. Posted by Leon (had 479 views)

    User (Old forums)
    Member
    Post 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)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.