Reputation: 880
I'm trying to set up a TEdit that will be used for research, so, it would be great to have a label displaying "current" / "count" over it, as observed by pressing CTRL + F in Google Chrome:
It seems that the TLabel control's always placed behind the TEdit control.
I also tried label1.BringToFront (Both at designtime and runtime), but it had no effect. Is there a way to place a label over an edit control?
Upvotes: 2
Views: 1524
Reputation: 1956
TLabel
inherits from TGraphicControl
which cannot be shown on top of windowed controls, no matter how many times you try to use BringToFront
it's just not going to happen.
However, you can use a container control such as a TPanel
that can be used to contain your TEdit
and TLabel
controls, see this image as an example:
That is a quick and dirty way, it's simply a TPanel
containing a TEdit
and TLabel
as child controls
The preferred way however is to create your own control which would give you full flexibility. Often trying to piece together multiple VCL controls to appear and function how you want is not usually ideal, and so by doing it the custom way gives you more freedom and possibilities.
Upvotes: 2