How to get DBGrid to draw Yes/No rather than True/False
I'm trying to replace True/False with Yes/No in a DBGrid. The code below
almost works:
procedure TDatamodule1.DBGridDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State:
TGridDrawState);
var
sText : String;
begin
if (UpperCase(Column.Field.FieldName) = UpperCase('Approved')) or
(UpperCase(Column.Field.FieldName) = UpperCase('Obsolete')) then
begin
if Column.Field.Value = True then
sText := 'Yes'
Else
If Column.Field.Value = False Then
sText := 'No'
Else
sText := '';
(Sender as TDBGrid).Canvas.FillRect(Rect);
(Sender as TDBGrid).Canvas.TextRect(Rect, Rect.Left+3, Rect.Top+2,
sText);
end;
end;
This appeared to work until I started using the keyboard cursor keys to
move around the grid. The cell that has the focus always has both True and
Yes or False and No drawn on top of each other. How do I prevent the
default True/False label from being drawn on the cell that has focus? All
other cells of the grid are perfect.
Thanks in advance.
No comments:
Post a Comment