Improve company productivity with a Business Account.Sign Up

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

StringGrid and combobox


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
syloux
Asked:
syloux
  • 5
1 Solution
 
Tom KnowltonWeb developerCommented:
Yes, it is possible.

I had code for that somewhere...hmmmm....
0
 
DraregCommented:

You can find a good example doing that at :

http://www.geocities.com/mshkolnik/FAQ/strgrid.zip 
0
 
FelixinCommented:
Are the items of the comobox stored in a Table?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Tom KnowltonWeb developerCommented:
Yes, it is possible.

I had code for that somewhere...hmmmm....
0
 
Tom KnowltonWeb developerCommented:
Yes, it is possible.

I had code for that somewhere...hmmmm....
0
 
Tom KnowltonWeb developerCommented:
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
 
Tom KnowltonWeb developerCommented:
I would go with Drareq's example...much better than my quick-n-dirty solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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