Lazarus

Programming => LCL => Topic started by: Jvan on May 15, 2021, 10:40:26 pm

Title: A multicolumn combobox?
Post by: Jvan on May 15, 2021, 10:40:26 pm
Is there such a control?


Thanks.
Title: Re: A combobo with a StringGrid?
Post by: VTwin 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.
Title: Re: A combobo with a StringGrid?
Post by: winni 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
Title: Re: A combobo with a StringGrid?
Post by: Jvan on May 15, 2021, 11:25:03 pm
Like this image:
Title: Re: A combobo with a StringGrid?
Post by: winni 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?
Title: Re: A combobo with a StringGrid?
Post by: VTwin 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.
Title: Re: A multicolumn combobox?
Post by: jamie 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.
Title: Re: A multicolumn combobox?
Post by: Jvan 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.  
Title: Re: A multicolumn combobox?
Post by: jamie 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.

TinyPortal © 2005-2018