[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3637
  • Last Modified:

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
0
klompen
Asked:
klompen
1 Solution
 
LimbeckCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now