Solved

StringGrid and combobox

Posted on 2001-06-05
7
719 Views
Last Modified: 2010-04-06

Is it possible to put a combobox on a cell on a StringGrid ?  I'm using Delphi 5, and I want the user to select data from a combobox on cell 1, and type data for other cells.

thanks
0
Comment
Question by:syloux
  • 5
7 Comments
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 6156831
Yes, it is possible.

I had code for that somewhere...hmmmm....
0
 
LVL 2

Accepted Solution

by:
Drareg earned 100 total points
ID: 6156857

You can find a good example doing that at :

http://www.geocities.com/mshkolnik/FAQ/strgrid.zip 
0
 
LVL 2

Expert Comment

by:Felixin
ID: 6156862
Are the items of the comobox stored in a Table?
0
Industry Leaders: 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!

 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 6156875
Yes, it is possible.

I had code for that somewhere...hmmmm....
0
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 6156913
Yes, it is possible.

I had code for that somewhere...hmmmm....
0
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 6156919
You can create one dynamically at run time.
In this example you start with a blank form, drop a stringgrid on the form and a button (to close the app).

Click on a cell of the stringgrid and a combobox will be created inside the string grid.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    ComboBox1: TComboBox;
    procedure Button1Click(Sender: TObject);
    procedure StringGrid1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.StringGrid1Click(Sender: TObject);
var
  TempComboBox : TComboBox;
begin
  TempComboBox := TComboBox.Create(self);
  TempComboBox.Parent := StringGrid1;
  TempComboBox.Width := 100;
  TempComboBox.Height := 50;
  TempComboBox.Top := 1;
  TempComboBox.Left := 1;
  TempComboBox.Items.Add('One');
  TempComboBox.Items.Add('Two');
  TempComboBox.Items.Add('Three');
  TempComboBox.Visible := true;
 // TempComboBox.Free;
end;

end.
0
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 6156975
I would go with Drareq's example...much better than my quick-n-dirty solution.
0

Featured Post

Independent Software Vendors: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 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