Recent

Author Topic: Force Picklist in TStringGrid to drop down  (Read 880 times)

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Force Picklist in TStringGrid to drop down
« on: June 05, 2023, 06:10:15 pm »
Is there a method/property that I can use to force a picklist in a TStringGrid cell to drop down?

I've looked quite hard, but I'm not sure if I need to look at the cell or column properties, or at the TStringGrid itself.

Thank you for the help!

jamie

  • Hero Member
  • *****
  • Posts: 6733
Re: Force Picklist in TStringGrid to drop down
« Reply #1 on: June 05, 2023, 09:17:07 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.  StringGrid1.Editor :=  StringGrid1.EditorByStyle(cbsPickList);
  4.  StringGrid1.Editor.Show;
  5.  StringGrid1.Editor.Left := StringGrid1.CellRect(1,1).Left;
  6.  StringGrid1.Editor.Top  := StringGrid1.CellRect(1,1).Top;
  7.  STringGrid1.Editor.Width:= StringGrid1.CellRect(1,1).Width;
  8. end;                                                        
  9.  

Something like this ?
The only true wisdom is knowing you know nothing

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Force Picklist in TStringGrid to drop down
« Reply #2 on: June 05, 2023, 10:08:16 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.  StringGrid1.Editor :=  StringGrid1.EditorByStyle(cbsPickList);
  4.  StringGrid1.Editor.Show;
  5.  StringGrid1.Editor.Left := StringGrid1.CellRect(1,1).Left;
  6.  StringGrid1.Editor.Top  := StringGrid1.CellRect(1,1).Top;
  7.  STringGrid1.Editor.Width:= StringGrid1.CellRect(1,1).Width;
  8. end;                                                        
  9.  

Something like this ?


Almost. I want to force that picklist to drop down - equivalent to pressing Alt-Down on the keyboard.

jamie

  • Hero Member
  • *****
  • Posts: 6733
Re: Force Picklist in TStringGrid to drop down
« Reply #3 on: June 05, 2023, 11:06:54 pm »
The onSelectEditor gives you the control that is currently in place as far as Know.

When you reach that event you can do this.

TCustomCombobox(Editor).DroppedDown := true;

Of course it maybe a smart idea to first test it.

 Editor As TCustomCombobox.DroppedDown := True;
The only true wisdom is knowing you know nothing

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Force Picklist in TStringGrid to drop down
« Reply #4 on: June 06, 2023, 07:43:21 am »
Yes, that looks like the property I was looking for. I will certainly test it out!

Thanks again.

 

TinyPortal © 2005-2018