Solved

StringGrid and combobox

Posted on 2001-06-05
7
714 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: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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:knowlton
ID: 6156875
Yes, it is possible.

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

Expert Comment

by:knowlton
ID: 6156913
Yes, it is possible.

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

Expert Comment

by: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:knowlton
ID: 6156975
I would go with Drareq's example...much better than my quick-n-dirty solution.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

861 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