Solved

String or drawGrid

Posted on 2003-11-25
1
290 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

20 Experts available now in Live!

Get 1:1 Help Now