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
klompenAsked:
Who is Participating?
 
LimbeckConnect With a Mentor Commented:
hi, maybe you can use this

http://www.bradtrupp.com/id/hax252.html
0
 
MerijnBSr. Software EngineerCommented:
does it have to be a stringgrid, or something which can display data as a grid?

if so, take a look at VirtualStringTree: http://www.delphi-gems.com/index.php?option=com_content&task=view&id=12&Itemid=38
0
 
diniludCommented:
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]:=IntToStr(i);
     if i mod 2=0 then
       StringGrid1.Cells[1,i]:='True'
     else StringGrid1.Cells[1,i]:='False';
   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.FillRect(Rect);
     if SameText(StringGrid1.Cells[ACol-1, ARow],'True') then
       DrawFrameControl(StringGrid1.Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK or DFCS_CHECKED)
     else DrawFrameControl(StringGrid1.Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONCHECK)
   end
   else StringGrid1.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, StringGrid1.Cells[ACol, ARow]);
end;

end.
0
 
klompenAuthor Commented:
Thanks
0
 
LimbeckCommented:
glad to be of help. :)

Ed
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.