TAdvColumnGrid with CheckBox Column

This is with VCL UI Pack 10.1.2.0.

I'm trying to setup a TAdvColumnGrid with a non-fixed column 0 with an always shown checkbox.

I have the Column->Editor =  edCheckBox.

ColumnGrid->ControlLook->CheckAlwaysActive = true;
ColumnGrid->Options->goEditing = true;
ColumnGrid->Options->AlwaysShowEditor = true;

However, the checkbox only appears if I click on the cell, but disappears once I leave the cell showing either 'Y' or 'N' instead of a checkbox.

Am I missing a setup in configuring this?  Do I need to use AddCheckBox or AddCheckBoxColumn?  I've looked for an example, but I've only found examples for TAdvStringGrid.


For always visible checkboxes please use grid.AddCheckBox() or grid.AddCheckBoxColumn(). This also applies to TAdvColumnGrid (which descends from TAdvStringGrid)

Bruno,

Thanks.  Most of my experience is with TDBAdvGrid which is also a descendant of TAdvStringGrid, so I was trying to set it up in a similar manner.

I've gotten AddCheckBox() to display an always visible checkbox, but have run into an issue with banding under certain conditions.

Here's a normal screenshot.


After deleting a row:



The banding of the checkboxes is no longer correct after executing RemoveRows().  I've also tried executing a RemoveCheckBox() prior to RemoveRows().  Not sure if that is required?   I've also tried manually calling Refresh().

Any ideas?

We could reproduce this and we're investigating.
Meanwhile as a workaround & alternative to using bands, implement grid.OnGetCellColor with something like:

procedure TForm1.AdvColumnGrid1GetCellColor(Sender: TObject; ARow,
  ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
  if odd(ARow) then
    ABrush.Color := clInfoBk;
end;

Bruno,

Thanks for the workaround.

So, a question regarding the checkbox behavior with the column grid.  Do the TGridColumnItem properties have any affect on the operation of a checkbox added with AddCheckBox()?  I've been trying to alter the CheckFalse / CheckTrue values, but they are remaining set to 'N' / 'Y'....

The last parameter of the AddCheckBox() method determines if the checkbox state is related to a cell value of CheckTrue/CheckFalse or not.
Described in manual http://www.tmssoftware.biz/download/manuals/TMS%20TAdvStringGrid%20Developers%20Guide.pdf

on page 71

Hi,

I appreciate this is an old post, but I found it when trying to find out why setting CheckFalse / CheckTrue values in the TGridColumnProperties don't work.

If we rely on the TGridColumnProperties to edit the cell as a checkbox, that editor always appears to set Y or N, it does not appear to set the text we have stipulated in CheckFalse / CheckTrue.

It would be useful to have the invoked editor set the value to the values of CheckFalse / CheckTrue provided at least one of them is set to a non-zero length string. (So one of them could be as showing a blank cell could be appropriate).

Thanks for your fantastic components, and for considering this request.

I retested this here with a default TAdvColumnGrid and the code:

procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.Items.Add(AdvColumnGrid1.Cells[1,1]);
listbox1.Items.Add(AdvColumnGrid1.Cells[2,1]);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
advcolumngrid1.Columns[1].CheckFalse := '0';
advcolumngrid1.Columns[1].CheckTrue := '1';

advcolumngrid1.Columns[2].CheckFalse := 'F';
advcolumngrid1.Columns[2].CheckTrue := 'Y';

advcolumngrid1.AddCheckBox(1,1,false,true);
advcolumngrid1.AddCheckBox(2,1,false,true);

end;

When clicking the checkbox in column 1, this results in value 0 or 1 in the cell and for column 2 in value N or Y, which is the expected behavior.