Solved

StringGrid and combobox

Posted on 2001-06-05
7
713 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

17 Experts available now in Live!

Get 1:1 Help Now