klompen
asked on
CheckBox in StringGrid
Hi,
Is there any good (preferebly free) TStringGrid component that you can have CheckBox type column?
I know that TMS software has one, but I dont like it because it needs "gdiplus.dll" which sometimes does not exist.
JEDI VCL TJvStringGrid does not have this feature :(
So, anyone know or have the code and willing to share?
Thanks
Is there any good (preferebly free) TStringGrid component that you can have CheckBox type column?
I know that TMS software has one, but I dont like it because it needs "gdiplus.dll" which sometimes does not exist.
JEDI VCL TJvStringGrid does not have this feature :(
So, anyone know or have the code and willing to share?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i think this is the basic in implimentation of check box in stringgrid
Unit1. dfm
=========
object Form1: TForm1
Left = 250
Top = 229
Width = 253
Height = 208
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 0
Top = 0
Width = 233
Height = 161
ColCount = 3
TabOrder = 0
OnDrawCell = StringGrid1DrawCell
RowHeights = (
24
24
24
24
24)
end
end
Unit1.pas
========
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure StringGrid1DrawCell(Sender : TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var i:Integer;
begin
for i:=1 to 4 do
begin
StringGrid1.Cells[0,i]:=In tToStr(i);
if i mod 2=0 then
StringGrid1.Cells[1,i]:='T rue'
else StringGrid1.Cells[1,i]:='F alse';
end;
end;
procedure TForm1.StringGrid1DrawCell (Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (ARow>0) and (ACol=2) then
begin
StringGrid1.Canvas.FillRec t(Rect);
if SameText(StringGrid1.Cells [ACol-1, ARow],'True') then
DrawFrameControl(StringGri d1.Canvas. Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK or DFCS_CHECKED)
else DrawFrameControl(StringGri d1.Canvas. Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK)
end
else StringGrid1.Canvas.TextRec t(Rect, Rect.Left+2, Rect.Top+2, StringGrid1.Cells[ACol, ARow]);
end;
end.
Unit1. dfm
=========
object Form1: TForm1
Left = 250
Top = 229
Width = 253
Height = 208
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 0
Top = 0
Width = 233
Height = 161
ColCount = 3
TabOrder = 0
OnDrawCell = StringGrid1DrawCell
RowHeights = (
24
24
24
24
24)
end
end
Unit1.pas
========
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure StringGrid1DrawCell(Sender
Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var i:Integer;
begin
for i:=1 to 4 do
begin
StringGrid1.Cells[0,i]:=In
if i mod 2=0 then
StringGrid1.Cells[1,i]:='T
else StringGrid1.Cells[1,i]:='F
end;
end;
procedure TForm1.StringGrid1DrawCell
Rect: TRect; State: TGridDrawState);
begin
if (ARow>0) and (ACol=2) then
begin
StringGrid1.Canvas.FillRec
if SameText(StringGrid1.Cells
DrawFrameControl(StringGri
else DrawFrameControl(StringGri
end
else StringGrid1.Canvas.TextRec
end;
end.
ASKER
Thanks
glad to be of help. :)
Ed
Ed
if so, take a look at VirtualStringTree: http://www.delphi-gems.com/index.php?option=com_content&task=view&id=12&Itemid=38