views:

300

answers:

2

Does nybody know how to limit the number of rows the user can select in a cxGrid where MultiSelect is active?

The Grid is working in GridMode = True - because the amount of data is really big (200.000 rows). - Now if you press CTRL+A all rows are loaded because the grid wants to select them all.

Any tipps?

Thank you

A: 

One way would be to deactivate Ctrl-A in your Form by creating a shortcut that would preempt it. Just an idea, but it should work.

François
This definitely a work arround, but since I am trying to create a component (derived form cxgrid) that we can use anywhere in our application i would really like to find a way to fix this inside the component.
JPS
A: 

Try this in your CanSelectRecord event -

if Sender.Controller.SelectedRecordCount > x then
    AAllow := False;

Where 'x' is the limit you want.

yozey
In Gridmode False this works perfeclty (but is not needed anyway, since strg+a is no problem) - now in Gridmode True the event is still called very often (i asume each row) but "SelectedRecordCount" sadly stays at Zero constantly.Still the Event might be a good place to start. Maybe i find a counter that is going up somewhere in the data structure - or i might start my own counting when strg+a is pressed.
JPS
I just did my own counting in the event.. it won't cure the problem, because yes, i can disallow the selecting of each row. - But that doesn't stop the selection process. - The cxGrid continues to go through all rows and tries to select them. (So still everything is loaded and it takes forever)
JPS