By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,467 Members | 1,448 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,467 IT Pros & Developers. It's quick & easy.

align a label in center hor and vertical

P: n/a
Hi,

I want to add a Label on a panel programatically. No problem. But I
can't seems to manage that the label is centered horizontal and vertical
in the panel. I experimented with TextAlign and Dock but no real
success. I probably forget something. Some hints really welcome :)

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Jan 31 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 31 ene, 21:44, Wilfried Mestdagh <wilfr...@mestdagh.bizwrote:
Hi,

I want to add a Label on a panel programatically. No problem. But I
can't seems to manage that the label is centered horizontal and vertical
in the panel. I experimented with TextAlign and Dock but no real
success. I probably forget something. Some hints really welcome :)

--
rgds, Wilfried [MapPoint MVP]http://www.mestdagh.biz
Hi,
You mean align text or align position?

you could use:

Label lbl //...

lbl.position.x = panel.width/2 - lbl.width/2; //horizontal
lbl.position.y = panel.height/2 - lbl.height/2; //vertical
___
http://elblogdehoracio.blogspot.com

Feb 1 '07 #2

P: n/a
On Jan 31, 12:44 pm, Wilfried Mestdagh <wilfr...@mestdagh.bizwrote:
Hi,

I want to add a Label on a panel programatically. No problem. But I
can't seems to manage that the label is centered horizontal and vertical
in the panel. I experimented with TextAlign and Dock but no real
success. I probably forget something. Some hints really welcome :)
The only way I know of to centre things is to handle the resizing
events on the parent container and readjust the label's position
accordingly... "manually" as it were.

In other words, do a take on Horacio's solution, but you have to do it
whenever the parent container changes size.

Feb 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.