[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 737
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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