Solved

String or drawGrid

Posted on 2003-11-25
1
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
QRReport  TQrmemo vertical stretching 1 68
Graphics32 under Delphi 10.1 Berlin 2 187
Installshield for Embarcadero EX 10.1 Berlin 4 93
DBCtrlGrid, Delphi, Scroll 8 88
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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