473,563 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rotating Text in a Label Control

I want to rotate it 180 degree so it is upside down. What is the easiest way to accomplish this?

Thank you
John
Nov 20 '05 #1
6 29593
Hi,

Private Sub Label1_Paint(By Val sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Label1.Paint
Label1.Text = ""
e.Graphics.Tran slateTransform( Label1.ClientSi ze.Width,
Label1.ClientSi ze.Height)
e.Graphics.Rota teTransform(180 )
e.Graphics.Draw String("upside down string", Label1.Font,
Brushes.Black, RectangleF.op_I mplicit(Label1. ClientRectangle ))
End Sub

Ken
------------------
"jcrouse" <an*******@disc ussions.microso ft.com> wrote in message
news:CE******** *************** ***********@mic rosoft.com...
I want to rotate it 180 degree so it is upside down. What is the easiest
way to accomplish this?

Thank you,
John

Nov 20 '05 #2
Ken
Worked AWESOME, as you know. I am also trying to "middle.cen ter" the text in the box. I've tried about ten different ways. What code do I need to add and where does it need to go

Thanks for your help
John
Nov 20 '05 #3
Hi,

Use a string format

Private Sub Label1_Paint(By Val sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles Label1.Paint
Dim sf As New StringFormat
sf.Alignment = StringAlignment .Center
sf.LineAlignmen t = StringAlignment .Center
Label1.Text = ""
e.Graphics.Tran slateTransform( Label1.ClientSi ze.Width,
Label1.ClientSi ze.Height)
e.Graphics.Rota teTransform(180 )
e.Graphics.Draw String("upside down string", Label1.Font,
Brushes.Black, RectangleF.op_I mplicit(Label1. ClientRectangle ), sf)
End Sub
Ken
------------------------
"jcrouse" <an*******@disc ussions.microso ft.com> wrote in message
news:F5******** *************** ***********@mic rosoft.com...
Ken,
Worked AWESOME, as you know. I am also trying to "middle.cen ter" the
text in the box. I've tried about ten different ways. What code do I need
to add and where does it need to go?

Thanks for your help,
John

Nov 20 '05 #4
Ken...One more question about this. I am now trying to rotate text either 90 degrees or 270 degrees. I'm not sure of direction yet. Here is my code based on your earlier example:

Private Sub Label14_Paint(B yVal sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles Label14.Paint
Dim sf As New StringFormat
sf.Alignment = (StringAlignmen t.Center)
sf.LineAlignmen t = (StringAlignmen t.Center)
Label14.Text = ""
e.Graphics.Tran slateTransform( Label14.ClientS ize.Width, Label14.ClientS ize.Height)
e.Graphics.Rota teTransform(90)
e.Graphics.Draw String(Label4.T ext, Label14.Font, Brushes.Black, RectangleF.op_I mplicit(Label14 .ClientRectangl e), sf)
End Sub

When I display the form....the text is not visible at all. Any idead?

Thanks,
John
Nov 20 '05 #5
Well...here's some more information. If I use an angle of 180 it's right in the center of the label box. If i slowly increment it by 10 degrees at a time it seems to swing on a radius that is centered in the lower right hand corner of the label box. Either the first or last "eGraphics" line need to take into account the size of the label box and probably somehow divide something in half. I've tried for about two hours now but not understanding the parameters on those two lines completely makes it quite difficult to decipher

Ideas
John
Nov 20 '05 #6
Well...here's some more information. If I use an angle of 180 it's right in the center of the label box. If i slowly increment it by 10 degrees at a time it seems to swing on a radius that is centered in the lower right hand corner of the label box. Either the first or last "eGraphics" line need to take into account the size of the label box and probably somehow divide something in half. I've tried for about two hours now but not understanding the parameters on those two lines completely makes it quite difficult to decipher

Ideas
John
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2096
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the images, even worse they are not loading completely. This version includes a (vain) attempt at forcing the banner images to cache. Apart form the...
7
1897
by: Tim Marshall | last post by:
Text boxes that are not grouped with a data control seem to cause my screen to flutter when the mouse passes over it. Does anyone know why this might be? -- Tim - http://www.ucs.mun.ca/~tmarshal/ ^o< /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake /^^ "What's UP, Dittoooooo?" - Ditto
1
1524
by: MLH | last post by:
I see in A97 HELP that rotating text in charts is possible. What about labels on forms and reports?
7
2913
by: Mike Casey | last post by:
Hello all, I have ASP.NET label controls tied to a datasource (so text will vary in length depending on the record). In IE everything looks great--text is wrapped if needed. In Netscape and Opera, the text extends horizontally and does not wrap. Any ideas would be most appreciated! Thanks,
7
19524
by: Joe | last post by:
I have a label control that will be filled with text at runtime. The length of the text will vary, but the label must stay the same size. Is there a way to set the font size of the text such that it completely fills the label? For example, if the text is "Santa Claus" the font size might have to be 130 points to fill up a 637x476 label,...
1
3873
by: | last post by:
I have a label control that I've embedded in a datalist template. I will be binding data to that label. I want to run a string formatting function on the database text before it is injected into the datalist. When I try to do this, I get a "... does not exist in the current context. I need to know how to target the control. If I were...
1
1276
by: TH | last post by:
Could anyone please explain the bizarre and utterly infuriating effect I am observing while adding controls programmatically? I've reduced the problem to the following code: <form id=Form1 method=post runat="server"> <asp:label id=Label1 runat="server"/><BR> <asp:Label id=Label2 runat="server"/><BR> <asp:Button id=Button1 runat="server"...
12
13161
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the same Tag number. (I thought it might help) The checkboxes name is a concatenation of "chkCancel" and a number that represents the order in which...
18
24942
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
0
7665
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...
0
7583
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...
0
8106
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...
1
7642
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...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
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...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.