[D10.2] DBGrid et CheckBox
Bonjour,
Je souhaite gérer une CheckBox dans une colonne de ma DBGRid, pour cela j'utilise DrawFrameControl mais malheureusement il affiche parfois 'vrai' ou faux' lorsque l'on clic sur la CheckBox.
J'ai mis dgEditing à True dans les options de ma DBGRid, DefaultDrawing à True et j'utilise l'évènement OnDrawColumnCell comme ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
procedure TMaFrame.CRDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
const
IsChecked : array[Boolean] of Integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED);
var
DrawState: Integer;
begin
if (Column.Field.FieldName = 'MaColonne') then
begin
DrawState := ISChecked[Column.Field.AsBoolean];
TCRDBGrid(Sender).Canvas.FillRect(Rect);
DrawFrameControl(TCRDBGrid(Sender).Canvas.Handle, Rect, DFC_BUTTON, DrawState);
end;
end; |
J'ai fait beaucoup d'essais infructueux, je n'arrive pas à trouver comment éviter l'affichage de ce texte 'vrai ou faux' ?
EDIT : j'ai supprimé la variable DrawRect erreur de copié collé