Home Forums WinForms controls Xceed Grid for WinForms multi-select causes too many select events

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

    GridControl gc;
    gc.SelectedRowsChanged += new System.EventHandler(onSelectHandler);

    if I select 1st row, I get 1 call to onSelectHandler;
    if I then hold shift and select the 10th row. I get 9 calls to onSelectHandler.
    the first call has two rows select, the second call has 3 rows selected and so forth until the 9th call which will have 10 rows selected.

    I need the behavior where a multiselect only calls onSelectHandler after all 10 rows have been selected. Can anybody help?

    Imported from legacy forums. Posted by John (had 5920 views)

    User (Old forums)
    Member
    Post count: 23064

    Ask within onSelectHandler, how much rows are currently selected.
    If ten is the result, then do what you want. Does this help?

    Regards, Mario

    Imported from legacy forums. Posted by mario.muja (had 371 views)

    User (Old forums)
    Member
    Post count: 23064

    well the problem is i dont know how many things are selected at the time. when the event gets fired i dont know 10 things are selected until it stops.

    Imported from legacy forums. Posted by John (had 355 views)

    User (Old forums)
    Member
    Post count: 23064

    If you use the following line, you can know how many rows are selected when you are in the event handler :

    private void gridControl1_SelectedRowsChanged(object sender, EventArgs e)
    {
    if( gridControl1.SelectedRows.Count == 10 )
    {
    //do what you need
    }
    }

    There is no way of knowing if the user is still selected more rows at that time however.

    Imported from legacy forums. Posted by André (had 402 views)

    User (Old forums)
    Member
    Post count: 23064

    this doesn’t work because i can’t hard code 10. My use case is that when the select event gets fired i need to publish my own select event in my framework. Its working right now but its being very slow because when i select multiselect 100 things it fires the select event 100 times instead of 1 time. the first time it fires it has SelectedRows.Count == 1, then second time it fires it has SelectedRows.Count == 2 and so forth. I need to know when it is the last select event and then fire my publish select to my framework. My current work around is to start a timer for about half a second then publish my select event. But i do believe this is a bug in the xceed grid side.

    Imported from legacy forums. Posted by John (had 579 views)

    User (Old forums)
    Member
    Post count: 23064

    I guess i need to clarify a little more too. This is a user selection. It could be 100 rows or 10 rows or 2 rows or even 1 row.

    Imported from legacy forums. Posted by John (had 523 views)

    User (Old forums)
    Member
    Post count: 23064

    I understand your situation. There is not much else that can be done.

    By the way, that this is not a bug. This is by design. The event is fired for each row being selected.

    Imported from legacy forums. Posted by André (had 378 views)

    User (Old forums)
    Member
    Post count: 23064

    I feel it’s a bug. Because for one operation I’ll expect one event. The .Net datagridview raises only one event.

    Imagine the user doing ‘Select All’ operation. In this case if there are 1000 rows, 1000 times the event gets handled and the UI will hang.

    Imported from legacy forums. Posted by Vara (had 455 views)

    Xceed Support
    Member
    Post count: 5658

    Again, this is not a bug. Each selection is an operation by itself. That is why the SelectedRowsChanged event is triggered each time. This is a design decision.

    Imported from legacy forums. Posted by CharlesB (had 6495 views)

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