473,781 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

align a label in center hor and vertical

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
2 20538
On 31 ene, 21:44, Wilfried Mestdagh <wilfr...@mestd agh.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.bi z
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
On Jan 31, 12:44 pm, Wilfried Mestdagh <wilfr...@mestd agh.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
274541
by: Axel Dahmen | last post by:
Hi, I'd like to align a <div> within the center of the visual canvas. The text within the div should be left-aligned. How can I possibly achieve this? So far I can only align text blocks centrally by using <table align="center" .... . Is this also possible for vertical alignment? TIA, Axel Dahmen
1
5537
by: 50295 | last post by:
Hi! I'm trying to set the align property/attribute of an IFrame to center but its not working (see below). Can anyone please tell me what's going on, and if there's a work around for this? Thanks, - Olumide
2
4173
by: Cybertof | last post by:
Hello, Have you seen that if you try to right align multiple labels with different content, the labels are not aligned correctly ? Is it normal ? Cybertof.
3
8686
by: Tom Bernsen | last post by:
This should be simple, I did it with a datagrid easily enough. Using VS Net 1.1, I want a label over the datagrid and a hyperlink below it (from WebForms toolbox), with BOTH of them centered (text and control) over the page. In other words, everything centered, automatic with window size. If you have a solution not using VS (or HTML substitutes but would prefer using VS controls, clearly need datagrid and aspx), I'm all ears also. ...
7
4182
by: ALI-R | last post by:
Hi All, I have two user controls (header and footer) ,,which I've placed in an HTML Table in a page.I set the **align="center"** in the table and the table still is on the left side of the page .How can I get the whole page(Table and its user controls) aligned in the center of my page? Thanks for your time in advance. Ali
11
25392
by: Ben Amada | last post by:
Hello, When centering a block of HTML, in the past, I've always used: <div align="center"> ... </div> However, in VS 2005, I get the following warning: "Validation (XHTML 1.0 Transitional): Attribute 'align' is considered outdated. A newer construct is recommended."
2
11191
by: Steve Richter | last post by:
I want my panel to have an inner margin. Problem is label text does not appear to recognize the margin. In this example, the TextBox aligns on the margin, the label does not: <asp:Panel id="Panel1" runat="server" BackColor="gainsboro" Scrollbars=Both Style="margin:25px;" Height="200px" Width="300px">
1
2026
mickey0
by: mickey0 | last post by:
Hello, I would like to center 'Savi' but align=center seems dont' work on it. Any hints? thanks <html> <body> <table border="1"> <tr> <th align="center">Savi</th> </tr> <tr> <td>January</td>
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.