Solved

String or drawGrid

Posted on 2003-11-25
1
291 Views
Last Modified: 2010-04-16
How Can I Change column type of a string/drawgrid. for example I Want The First Column Of my grid contain a CheckBox Type, The Second Contains ComboBox, etc. ?
0
Comment
Question by:khalil_moghaddam
1 Comment
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 50 total points
ID: 9816926
you cannot change a stringgrid column type but you can draw your controls in cells....
this example puts a buttom in tstringgrid cells...

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, Buttons, StdCtrls;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    btn: TButton;
    procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure btnClick(Sender: TObject);
    private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  col, Row: Integer;
implementation

{$R *.dfm}
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var
sel: TRect;
begin

      Sel := StringGrid1.CellRect(Acol, Arow);
      SetWindowPos(btn.Handle, { handle }
              0,
              (StringGrid1.Left + 1) + ((Sel.Right )- (sel.Bottom-sel.Top)),
              Sel.Top + StringGrid1.top + 2,
              (sel.Bottom-sel.Top),
              Sel.Bottom - Sel.top ,
              SWP_NOZORDER or SWP_SHOWWINDOW);
      col := ACol;
      Row := ARow;
      btn.Show;
   
end;

procedure TForm1.btnClick(Sender: TObject);
begin
 SHowMessage('Selected Row '+IntToSTr(Row)+ ' in Column '+IntToSTr(Col));
end;

end.

F68 ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
A short film showing how OnPage and Connectwise integration works.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now