Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > Visual Studio 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 17th, 2006, 11:49 AM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Center Text within Label

Hi folks,

I know this is going to sound so stupid (really I have tried to look for the answer) how do you center text within a label on a web form in Visual Studio .NET 2005 (VB)??

Thanks

Reply With Quote
  #2 (permalink)  
Old January 17th, 2006, 11:59 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

A webform label control renders a <span> tag with the text inside of it. You can't really center the text side the span tag. However, you could center the span tag on the page using an standard HTML/CSS technique.

-Peter
Reply With Quote
  #3 (permalink)  
Old January 17th, 2006, 12:06 PM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter thanks for that, could you give me a little example just so I can get this clear in my head.

Thanks

Reply With Quote
  #4 (permalink)  
Old January 12th, 2007, 10:26 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This should work for you

label1.text = "<center>" & "Centered Text Here" & "</center>"

Reply With Quote
  #5 (permalink)  
Old February 9th, 2007, 10:02 AM
Registered User
 
Join Date: Jan 2007
Location: Greenock, Renfrewshire, United Kingdom.
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Pomegranete
Default

label1.text = "hello"
label1.textalign = center

That sould be a lot easier.

Pomegranete
Reply With Quote
The Following User Says Thank You to Pomegranete For This Useful Post:
nezar_alakhras (October 15th, 2011)
  #6 (permalink)  
Old October 15th, 2011, 12:59 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default thanks a lot

Quote:
Originally Posted by Pomegranete View Post
label1.text = "hello"
label1.textalign = center

That sould be a lot easier.

Pomegranete


i just registered to say a big thanks to u guy
i didnt know how to find it
but it was a lil bit diff
it was label1.textalign=ContentAlignment.MiddleCenter

but really thanks dear


Nezar Alakhras
Jordan -Amman
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to center text/image/any object into a div beetle_jaipur BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 3 January 24th, 2013 01:25 PM
center text (only) in fixed size div, how to do it beetle_jaipur BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 April 16th, 2007 01:38 PM
Center Text In ComboBox wb8bgy Visual Basic 2005 Basics 3 March 2nd, 2007 09:06 AM
Dynamic Text in Label funnylearning .NET Framework 2.0 2 September 18th, 2006 12:59 PM



All times are GMT -4. The time now is 11:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.