Hello
I need to validate a columns checkbox field. The problem is that CellValidating does not fire for CheckBox Columns
I put such code in checkbox change event of the dbAdvGrid but no success
procedure TFormAnagraficaMateriale.dbgMaterialeCheckBoxChange(Sender: TObject;
ACol, ARow: Integer; State: Boolean);
var
Value: Boolean;
begin
if (dbgMateriale.Columns[ACol].Name = 'colIPR') then
begin
if State then
begin
dbgMateriale.GetCheckBoxState(dbgMateriale.ColumnByName['colSRC'].Index,
ARow, Value);
if Value then
begin
ShowMessage('non possibile');
dbgMateriale.SetCheckBoxState(aCol,aRow,False);
end;
end;
end
else if (dbgMateriale.Columns[ACol].Name = 'colSRC') then
begin
if State then
begin
dbgMateriale.GetCheckBoxState(dbgMateriale.ColumnByName['colIPR'].Index,
ARow, Value);
if Value then
begin
ShowMessage('non possibile');
dbgMateriale.SetCheckBoxState(aCol,aRow,False);
end;
end;
end;
end;
I would like to prevent user to update checkbox columns having a cancel possibility
May you help me?
Thanks
There is currently not an event via which you could block the toggling of a checkbox when it is clicked. I'd assume it would offer a more intuitive user interface if checkboxes that can't be toggled are set as disabled?
I solve in this way using CanClickCell event hoping is it the best way...
Thanks
procedure TFormAnagraficaMateriale.dbgMaterialeCanClickCell(Sender: TObject;
ARow, ACol: Integer; var Allow: Boolean);
Var
valueSRC, valueIPR: Boolean;
begin
Allow := TRUE;
if (dbgMateriale.Columns[ACol].Name = 'colIPR') then
Begin
dbgMateriale.GetCheckBoxState(dbgMateriale.ColumnByName['colIPR'].Index,
ARow, valueIPR);
dbgMateriale.GetCheckBoxState(dbgMateriale.ColumnByName['colSRC'].Index,
ARow, valueSRC);
if (valueIPR = False) and (valueSRC) then
begin
MessageDlg
('Materiale di Prelievo. Non può essere caricato progressivamente',
mtWarning, [MbOk], 0);
Allow := False;
end;
End;
if (dbgMateriale.Columns[ACol].Name = 'colSRC') then
Begin
dbgMateriale.GetCheckBoxState(dbgMateriale.ColumnByName['colIPR'].Index,
ARow, valueIPR);
dbgMateriale.GetCheckBoxState(dbgMateriale.ColumnByName['colSRC'].Index,
ARow, valueSRC);
if (valueSRC = False) and (valueIPR) then
begin
MessageDlg
('Materiale caricato progressivamente. Non può essere di prelievo',
mtWarning, [MbOk], 0);
Allow := False;
end;
End;
end;