Recent

Author Topic: A multicolumn combobox?  (Read 1661 times)

Jvan

  • Full Member
  • ***
  • Posts: 181
A multicolumn combobox?
« on: May 15, 2021, 10:40:26 pm »
Is there such a control?


Thanks.
« Last Edit: May 15, 2021, 11:44:50 pm by Jvan »

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: A combobo with a StringGrid?
« Reply #1 on: May 15, 2021, 10:59:30 pm »
This is hard to follow. A ComboBox can select a StringGrid, but I find it hard to visualize what you want.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: A combobo with a StringGrid?
« Reply #2 on: May 15, 2021, 11:10:59 pm »
Hi!

If I got you right:

You want a ComboBox with a fly out 2 dimensional StringGrid???

What a crazy idea. But tell more about your design needs.

You can make a stringGrid invisible, you can resize it at runtime. Perhaps that helps.

Winni

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: A combobo with a StringGrid?
« Reply #3 on: May 15, 2021, 11:25:03 pm »
Like this image:

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: A combobo with a StringGrid?
« Reply #4 on: May 15, 2021, 11:32:01 pm »
Hi!

Create a ComboBox with the DataSources of your StringGrid.
If you click on an ComboBox item load the DataSource in your StringGrid.

Winni

PS.: Is it possible to get a beer or are there only tofu drinks?

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: A combobo with a StringGrid?
« Reply #5 on: May 15, 2021, 11:34:25 pm »
Got it.

You can do this with a ComboBox and a StringGrid. Reload the StringGrid when the ComboBox changes.

EDIT: Same as Winni said.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: A multicolumn combobox?
« Reply #6 on: May 16, 2021, 12:27:27 pm »
I guess the question is does it need to behave like a drop down? because currently a combobox has a small drop even without any content in it and you will also notice there are controls added to that form so this isn't a simple drop down and its not that easy with the LCL to draw directly on the drop down and keep it cross platform.

  Even in windows it's tricky to add controls to the drop down. I have done it but I wouldn't suggest it to greenies.

I think in this case a dedicated form with a basic button with a down array and string grid is warranted here.
The only true wisdom is knowing you know nothing

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: A multicolumn combobox?
« Reply #7 on: May 16, 2021, 05:37:40 pm »
I guess the question is does it need to behave like a drop down? because currently a combobox has a small drop even without any content in it and you will also notice there are controls added to that form so this isn't a simple drop down and its not that easy with the LCL to draw directly on the drop down and keep it cross platform.

  Even in windows it's tricky to add controls to the drop down. I have done it but I wouldn't suggest it to greenies.

I think in this case a dedicated form with a basic button with a down array and string grid is warranted here.

I have a problem with the main form borders and height values to set the position values (top and left):

Code: Pascal  [Select][+][-]
  1. procedure TForm1.EditButton1ButtonClick(Sender: TObject);
  2. begin
  3.   frmComboGrid.Top:=Form1.Top + EditButton1.Top + EditButton1.Height;
  4.   frmComboGrid.Left:=Form1.Left + EditButton1.Left ;
  5.   frmComboGrid.Show;
  6.   frmComboGrid.StringGrid1.SetFocus;
  7. end;
  8.  

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: A multicolumn combobox?
« Reply #8 on: May 16, 2021, 09:22:22 pm »
That will work if the Grid is a child control of the form in which case you can use the Anchor editor .

But I am thinking this is not the case..

Lets assume it is not, you can use the ClientToScreen function in the BUtton to obtain absolute screen cords and set the form for the grid using those factors since the form works from screen cords.

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018