Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2000, 08:05 AM
N/A
Guest
 
Posts: n/a
Default TDBCheckBox in a TDBGrid

I whant to use a TDBCheckBox in an TDBGrid and I knew that's possible but how.

Thanks a lot, Dietmar
Reply With Quote
  #2  
Old 05-21-2000, 01:00 AM
N/A
Guest
 
Posts: n/a
Default RE: TDBCheckBox in a TDBGrid

try to inherit a new grid and add to it
procedure Tnewgrid.DrawCheckBox(R: TRect; Checked : Boolean);
var
DrawState: Integer;
DrawRect: TRect;
AState: TCheckBoxState;
al: TAlignment ;
begin
al := taCenter; //aways make it centered much better
if Checked then AState := cbChecked else AState := cbUnChecked;

case AState of
cbChecked: DrawState := DFCS_BUTTONCHECK or DFCS_CHECKED;
cbUnchecked: DrawState := DFCS_BUTTONCHECK;
else // cbGrayed
DrawState := DFCS_BUTTON3STATE or DFCS_CHECKED;
end;
case al of
taRightJustify: begin
DrawRect.Left := R.Right - FCheckWidth;
DrawRect.Right := R.Right;
end;
taCenter: begin
// need update for right to left
DrawRect.Left := R.Left + (R.Right - R.Left - FCheckWidth) div 2;
DrawRect.Right := DrawRect.Left + FCheckWidth;
end;
else // taLeftJustify
DrawRect.Left := R.Left;
DrawRect.Right := DrawRect.Left + FCheckWidth;
end;
DrawRect.Top := R.Top + (R.Bottom - R.Top - FCheckWidth) div 2;
DrawRect.Bottom := DrawRect.Top + FCheckHeight;

DrawFrameControl(Canvas.Handle, DrawRect, DFC_BUTTON, DrawState);
end;

then
if ( ((ARow > 0) and (ACol >0)) and FExtColumns[ACol-1].CheckBox) then
begin
OldActive := DataLink.ActiveRecord ;
DataLink.ActiveRecord := Pred(ARow);
Status := FExtColumns[ACol-1].ParentColumn.Field.AsString = FExtColumns[ACol-1].CheckValue ;
DrawCheckBox(ARect, Status);
DataLink.ActiveRecord := OldActive;
End
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:34 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.