Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2006, 11:49 AM
Authorized User
 
Join Date: Dec 2005
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

 
Old January 17th, 2006, 11:59 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old January 17th, 2006, 12:06 PM
Authorized User
 
Join Date: Dec 2005
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

 
Old January 12th, 2007, 10:26 PM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This should work for you

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

 
Old February 9th, 2007, 10:02 AM
Registered User
 
Join Date: Jan 2007
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
The Following User Says Thank You to Pomegranete For This Useful Post:
nezar_alakhras (October 15th, 2011)
 
Old October 15th, 2011, 12:59 PM
Registered User
 
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.