cxgrid - set all checkboxes checked

5.9k views Asked by At

I am using the cxGrid. I have a field (column) in my grid that is of boolean type (true/false) represented in the grid as a checkbox. How can I make all the checkboxes in the column checked (or unchecked) on button click ?

it looks like this :

enter image description here

Now I would like, on button click, to turn those 3 checkboxes checked BEFORE I save everything.. DATA on the left(USERS) comes from a table, the data on the right is from a query. The SAVE of everything goes to a separate LOG table.

When I hit 'Check all' button,the result :

enter image description here

I could run the update query : update MYFIELD set SELECTED = '2'; but I am more interested in manipulating the grid itself.Something simple...

2

There are 2 answers

5
Jan Doggen On

You will have to add a button or pop up menu somewhere on your form to accept the check all 'command', or maybe even place a checkbox in your column header. Then go through your underlying dataset and set all field values. Don't forget a DisableControls/EnableControls.

0
user763539 On

added an extra field to my table (boolean type) and changed its property in the cxGrid to that of a checkbox.Then on button click:

with uniquery1 do begin
  Active:=False;
  sql.Clear;
  SQL.Add('update users set selected = 0'); //or '1'
  execSql;
end;
Uniquery1.Refresh;

this I found was the easiest way ....