mikepj
asked on
Dropdown list in DBGrid or StringGrid?
Hi,
I have Delphi 4--how can I display a dropdown list in the grid when the user goes to edit the field. What I need is for the user to be able to choose the data that goes in the field from a list of possible answers. I believe that Delphi 3 and 4 are both able to do this but I don't have a clue how. I don't want to use a DBComboBox but want similar functionality.
Thank you!
/MP
I have Delphi 4--how can I display a dropdown list in the grid when the user goes to edit the field. What I need is for the user to be able to choose the data that goes in the field from a list of possible answers. I believe that Delphi 3 and 4 are both able to do this but I don't have a clue how. I don't want to use a DBComboBox but want similar functionality.
Thank you!
/MP
ASKER
Viktor,
Thank you for your reply. It is very hard to make this work because of conflicts between the combo boxes and other problems that come up when you try to do strange things. There must be a better way...
Thank you,
/MP
Thank you for your reply. It is very hard to make this work because of conflicts between the combo boxes and other problems that come up when you try to do strange things. There must be a better way...
Thank you,
/MP
ASKER
Viktor,
Thank you for your reply. It is very hard to make this work because of conflicts between the combo boxes and other problems that come up when you try to do strange things. There must be a better way...
Thank you,
/MP
Thank you for your reply. It is very hard to make this work because of conflicts between the combo boxes and other problems that come up when you try to do strange things. There must be a better way...
Thank you,
/MP
I compiled it with Delphi and it worked fine . o O Is there any problem when you run it???
Regards,
Viktor Ivanov
Regards,
Viktor Ivanov
There are some excellent components out there which give you much greater functionality when using grids. If you are using data bound stuff, then InfoPower is a must. They provide to option to next picklists into grid without any difficulty.
Orpheus from TurboPower is powerful, but quite difficult to get going with. They are non-data bound and have functionality similar to a string grid.
Hope this helps.
Orpheus from TurboPower is powerful, but quite difficult to get going with. They are non-data bound and have functionality similar to a string grid.
Hope this helps.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
------------
SG - StringGrid which is same as DBGrid
CB - ComboBox which is same as any other dropdown control
In OnDrawCell() of the StrGrid do this....
procedure TForm1.SGDrawCell(Sender: TObject; Col, Row: Integer;
Rect: TRect; State: TGridDrawState);
begin
CB.Parent := SG;
if (col = 1) and (row = 1)then
with CB do begin
Width := Rect.Right div 2;
Height := Rect.Bottom;
Top := Rect.Top;
Left := Rect.Left;
end;
end;
-----------
Try the code out and just need to replace the ComboBox with a control that can drop down....
Regards,
Viktor Ivanov