473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 29543
Hi,

Private Sub Label1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
Label1.Text = ""
e.Graphics.TranslateTransform(Label1.ClientSize.Wi dth,
Label1.ClientSize.Height)
e.Graphics.RotateTransform(180)
e.Graphics.DrawString("upside down string", Label1.Font,
Brushes.Black, RectangleF.op_Implicit(Label1.ClientRectangle))
End Sub

Ken
------------------
"jcrouse" <an*******@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.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.center" 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(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
Label1.Text = ""
e.Graphics.TranslateTransform(Label1.ClientSize.Wi dth,
Label1.ClientSize.Height)
e.Graphics.RotateTransform(180)
e.Graphics.DrawString("upside down string", Label1.Font,
Brushes.Black, RectangleF.op_Implicit(Label1.ClientRectangle), sf)
End Sub
Ken
------------------------
"jcrouse" <an*******@discussions.microsoft.com> wrote in message
news:F5**********************************@microsof t.com...
Ken,
Worked AWESOME, as you know. I am also trying to "middle.center" 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(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label14.Paint
Dim sf As New StringFormat
sf.Alignment = (StringAlignment.Center)
sf.LineAlignment = (StringAlignment.Center)
Label14.Text = ""
e.Graphics.TranslateTransform(Label14.ClientSize.W idth, Label14.ClientSize.Height)
e.Graphics.RotateTransform(90)
e.Graphics.DrawString(Label4.Text, Label14.Font, Brushes.Black, RectangleF.op_Implicit(Label14.ClientRectangle), 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
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...
7
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 -...
1
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
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...
7
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...
1
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...
1
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...
12
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...
18
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
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...
0
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...
0
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,...

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.