Recent

Author Topic: I like TLabelledEdit, any chance of a TLabelledComboBox?  (Read 11037 times)

Exception

  • New Member
  • *
  • Posts: 10
I like TLabelledEdit, any chance of a TLabelledComboBox?
« on: June 02, 2021, 04:00:15 pm »
Hi,

I like TLabelledEdit quite a lot. It's handy to have the label and the edit box together. Which makes me think, why not a TLabelledComboBox?

 :)

Thanks!

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #1 on: June 02, 2021, 04:12:46 pm »
Being a heavy user of the anchor editor I strongly advise against the TLabelledEdit because it does not cooperate with the anchor editor nor with autosizing:

Put a TLabelledEdit on the form, open the anchor editor and set the top anchor of the LabelledEdit to the form --> the label will disappear (it will have move out of the form).

Or put a TLabelledEdit into a TPanel and set the panel's AutoSize to true --> the panel will shrink to zero height. On the other hand, when there is a simple TEdit inside the Panel, the autosize adjusts the size of panel to match that of the edit perfectly. And when there is also a TLabel inside the panel which you anchored to the TEdit, the autosized panel will enclose both label and edit.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #2 on: June 02, 2021, 04:26:55 pm »
Good to know. I commonly anchor TLabels to TEdits and TComboBoxes, and never tried TLabelledEdits.
“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)

Bart

  • Hero Member
  • *****
  • Posts: 5274
    • Bart en Mariska's Webstek
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #3 on: June 02, 2021, 10:13:05 pm »
Delphi has the same problem with this control.
It should have been designed as a compound control, like we have done with TEditButton etc.

Bart

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #4 on: June 02, 2021, 11:17:51 pm »
Delphi has the same problem with this control.
I checked both Delphi 7 and Delphi XE 10.3. Since Delphi does not have an anchor editor I cannot check its behaviour there. But when I put it into an auto-sized panel the size is correct, so that in encloses both label and edit - unlike Lazarus.

Bart

  • Hero Member
  • *****
  • Posts: 5274
    • Bart en Mariska's Webstek
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #5 on: June 03, 2021, 06:15:38 pm »
But aligning doesn't work correctly in D7

Bart

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #6 on: June 03, 2021, 07:14:08 pm »
Sorry to be insistent: What do you mean with "aligning"? There is no Align property for TLabeledEdit, neither in Delphi nor in Lazarus. There is an AlignWithMargins in newer Delphi versions, and this, in fact, does not consider the label, only the edit.

Exception

  • New Member
  • *
  • Posts: 10
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #7 on: June 03, 2021, 09:27:19 pm »
Being a heavy user of the anchor editor I strongly advise against the TLabelledEdit because it does not cooperate with the anchor editor nor with autosizing:

Put a TLabelledEdit on the form, open the anchor editor and set the top anchor of the LabelledEdit to the form --> the label will disappear (it will have move out of the form).

Or put a TLabelledEdit into a TPanel and set the panel's AutoSize to true --> the panel will shrink to zero height. On the other hand, when there is a simple TEdit inside the Panel, the autosize adjusts the size of panel to match that of the edit perfectly. And when there is also a TLabel inside the panel which you anchored to the TEdit, the autosized panel will enclose both label and edit.

Thanks, I'll have a play anchor editor. I confess I've never used. Pleased I made the post, as it looks like I might learning something new  :).

Joanna

  • Hero Member
  • *****
  • Posts: 723
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #8 on: June 23, 2021, 03:07:05 pm »
I use a frame containing a flowpanel with label and combobox  as a labeled combobox
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Exception

  • New Member
  • *
  • Posts: 10
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #9 on: July 02, 2021, 01:58:58 pm »
I use a frame containing a flowpanel with label and combobox  as a labeled combobox

I'll be honest, I'm not familiar with frames or flowpanels. I'll have to brush up.

Thanks.

Exception

  • New Member
  • *
  • Posts: 10
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #10 on: July 02, 2021, 02:05:06 pm »
I guess a more flexible way of doing things would be if you can somehow group different components together, so when you move one at design time, the other follows. I know you can do this with panels, but I find lots of panels a bit messy.

I notice, @wp, you mention "which you anchored to the TEdit" which maybe sounds like a method of doing that, but I couldn't find anything on the right click menu to link two visual components together.

Thanks.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: I like TLabelledEdit, any chance of a TLabelledComboBox?
« Reply #11 on: July 02, 2021, 04:20:38 pm »
I notice, @wp, you mention "which you anchored to the TEdit" which maybe sounds like a method of doing that, but I couldn't find anything on the right click menu to link two visual components together.
I mean this:
  • Place a TPanel on the form, delete the panel's Caption.
  • Add a TLabel and a TEdit to the panel
  • Right-click on the Edit and select "Anchor Editor" --> The window with the Anchor Editor appears.
  • In the combobox of the "Left anchoring" group of the Anchor Edit, select the label; in the combobox of the "Top anchoring" group, select the label, as well, but then click in the lower button in the vertical 3-button-group at the right - this puts the Edit below the label. (When you now drag the label somewhere the Edit always follows. If you try to drag the edit instead this will not work because the way we did the anchoring the edit position derives from the label position - of couse you can also link the controls in the opposite order by slightly changing the steps - try this on your own...)
  • Return to the form editor, select the panel. Go to the Object Inspector and set the panel's AutoSize to true --> Now the label and edit are moved into the upper left corner of the panel, but the anchoring makes the edit stay below the edit, and the size of the panel shrinks to tightly surround the two controls.

 

TinyPortal © 2005-2018