Jump to content
Ruud

Work-around for TEdit vertical alignment problem

Recommended Posts

This is how a normal TEdit looks like :

180938350_TEditvert-align1.png.69aeafeba7a47e95c404af637b7d725d.png

The text is horizontally aligned , but not vertically .

 

Relevant properties for Edit1 :
Alignment | taCenter
BevelWidth | 1
Height | 30
Width | 60

 

And this is how you want your TEdit to look like :

2029473560_TEditvert-align2.png.2b47ff69e1f0f3ab6a0757bdae2baeba.png

The text is both horizontally and vertically alligned !

 

The solution is quite simple : define a TEdit within a TPanel .

 

Relevant properties for Panel1 :

Alignment | taCenter
BevelWidth | 1
Height | 30
Width | 60

 

Relevant properties for Edit2 :

Alignment | taCenter
BevelWidth | 1
Height | 22
Left | 1
Top | 7
Width | 58

 

Ruud Schmeitz

Maastricht

 

Share this post


Link to post
5 hours ago, Ruud said:

The text is horizontally aligned , but not vertically .

I usually keep the default AutoSize = True setting. IMHO, this looks better than the large gaps above and below.

Share this post


Link to post
12 hours ago, Ruud said:

And this is how you want your TEdit to look like :

I agree with Uwe but if you really want the space around your edit area, perhaps put the edit box in a panel, check AlignWithMargins, and turn off the border for the text box.

Share this post


Link to post
17 hours ago, Uwe Raabe said:

I usually keep the default AutoSize = True setting. IMHO, this looks better than the large gaps above and below.

Unfortunately that doesn't work in my case .

With the chosen Font ( Verdana , 7) , AutoSize = True resizes the height of the TEdit to 20 , while (for some good reason) it must be 30 .

Share this post


Link to post
5 hours ago, Ruud said:

while (for some good reason) it must be 30

Well, in that case...

Share this post


Link to post

That feels like a bug to me.

Seems that panel should not affect that, or am I missing something obvious.

Vertical align into the edit would be quite nice to have. There must be palaces it would be useful. 

-tee-

Share this post


Link to post
1 hour ago, Tommi Prami said:

Vertical align into the edit would be quite nice to have.

As long as it is a native Windows control, we are limited by its internal functionality. Currently it doesn't support that: Edit Control Styles

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×