procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); const //这个整数值将按照布尔值返回,并送入数组 CtrlState:array[Boolean] of Integer = (DFCS_BUTTONCHECK,DFCS_BUTTONCHECK or DFCS_CHECKED); var flag:boolean; begin //确保只有在逻辑字段才能插入组件 if Column.FieldName = 'platform' then begin if (Column.Field.AsString = '1') then flag:= true else flag:=false; DrawFrameControl(DBGrid1.Canvas.Handle,Rect,DFC_BUTTON,CtrlState[FLAG]); end; end;
当然第三方组件都是个好方法http://lysoft.7u7.net
DataCol: Integer; Column: TColumn; State: TGridDrawState);
const
//这个整数值将按照布尔值返回,并送入数组
CtrlState:array[Boolean] of Integer = (DFCS_BUTTONCHECK,DFCS_BUTTONCHECK or DFCS_CHECKED);
var
flag:boolean;
begin
//确保只有在逻辑字段才能插入组件
if Column.FieldName = 'platform' then
begin
if (Column.Field.AsString = '1') then
flag:= true
else
flag:=false;
DrawFrameControl(DBGrid1.Canvas.Handle,Rect,DFC_BUTTON,CtrlState[FLAG]);
end;
end;