|
-
Jan 18th, 2009, 12:17 AM
#1
Thread Starter
Addicted Member
[2008] Rotate a label How?
Anyone have on how to rotate a label it in to vertical?
-
Jan 18th, 2009, 12:33 AM
#2
Re: [2008] Rotate a label How?
You can't. If you want to orient your text differently then you'll need to draw it using GDI+. GDI+ drawing is done on the Paint event of the control you want to draw on. This will draw text vertically on a form:
vb.net Code:
Public Class Form1 Private Sub Form1_Paint(ByVal sender As Object, _ ByVal e As PaintEventArgs) Handles Me.Paint e.Graphics.DrawString("Hello World", _ Me.Font, _ Brushes.Black, _ 10, _ 10, _ New StringFormat(StringFormatFlags.DirectionVertical)) End Sub End Class
You should read the documentation for the Graphics class, it's DrawString method and the StringFormat class, then experiment to see what else you can do.
-
Jan 18th, 2009, 05:51 AM
#3
Thread Starter
Addicted Member
Re: [2008] Rotate a label How?
it's works...but how can i place a label or move it into form
it place at the upper left and can't select to move a control...
how can i move the label..
-
Jan 18th, 2009, 06:07 AM
#4
Re: [2008] Rotate a label How?
I could quite easily answer your question but I'm not going to. It's my intention by posting here to help people become better developers. Handing people solutions on a plate that they could find for themselves relatively easily is not conducive to that end, as it doesn't develop people's investigative and problem solving skills. So, I'm going to reiterate my advice from my previous post:
You should read the documentation for the Graphics class, it's DrawString method and the StringFormat class, then experiment to see what else you can do.
If you do that then you'll have the answer to your question. In my example code I have passed six arguments to DrawString. What is each of those values for? If you don't know then you haven't read the documentation. Here's where you should start:
http://msdn.microsoft.com/en-us/libr....graphics.aspx
That's the documentation for the Graphics class. Once you've read that you can follow the link provided for the member listing. You can then follow the link from there to the topic for the DrawString method. You can then see the different ways it can be called and what each argument represents. Once you've done that you'll be able to answer your own question and you'll (hopefully) have learned more besides, including how to find information in the future. That will be far more beneficial to you as a developer than my simply answering your question.
-
Jan 18th, 2009, 06:39 AM
#5
Thread Starter
Addicted Member
Re: [2008] Rotate a label How?
another thing....what if i want to rotate progress bar or other controls like picturebox...
do i have to do that as your code below?
-
Jan 18th, 2009, 07:27 AM
#6
Re: [2008] Rotate a label How?
You cannot rotate controls. The ProgressBar control supports horizontal orientation only in Windows Forms. In Windows Presentation Foundation (WPF) it supports vertical too.
With regards to images, again, PictureBoxes cannot be rotated. If you want to display an image rotated then you must either rotate the Image object itself, which you can do in increments of 90 degrees with the RotateFlip method, or else you use GDI+ as for the text to draw the Image directly onto the form or another control. You call DrawImage to draw an Image but rotating one is a little more complex. Check out the following threads for examples.
http://www.vbforums.com/showthread.php?t=537099
http://www.vbforums.com/showthread.php?t=519149
-
Jan 18th, 2009, 08:28 AM
#7
Thread Starter
Addicted Member
Re: [2008] Rotate a label How?
if i not to rotate a progress bar...
so i need to draw it right?
But how i can do that...
-
Jan 18th, 2009, 04:56 PM
#8
Re: [2008] Rotate a label How?
There are definitely third party progress bar controls available that can be displayed vertically, although they may not look like the standard control.
To draw one yourself you have a few options. You could just use a Label or Panel and set its BackColor, changing the Height as the progress changes. You could also use GDI+ again and call FillRectangle. Finally, you could use the RectangleShape (I think it's called) from the VB PowerPacks, which gets added to the Toolbox with SP1.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|