Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Rotating a linklabel control

I think the title says it all really. I need to have a linklabel control rotate to 90 degrees. I have read hints about overloading the onpaint method of the control but I'm new to .Net and i'm not sure if this is the best way, or how to go about it.

Thanks for your time,
Dan
0
zomby_dog
Asked:
zomby_dog
  • 2
1 Solution
 
RonaldBiemansCommented:
Hi Zomby_dog,

When the problem really isn't the rotating of the label because that is simple,

    Private Sub LinkLabel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles LinkLabel1.Paint
        Dim fg As New Font(LinkLabel1.Font, FontStyle.Underline)
        Dim g As New StringFormat

        g.FormatFlags = StringFormatFlags.DirectionVertical
        e.Graphics.FillRectangle(New SolidBrush(LinkLabel1.BackColor), LinkLabel1.DisplayRectangle)
        e.Graphics.DrawString(LinkLabel1.Text, fg, New SolidBrush(Color.Blue), 0, 0, g)
    End Sub

the real problem is that you loose all the functionality of the linklabel class, which means you have to write your own class to accomodate the things like color change and mouse pointer changes.

0
 
zomby_dogAuthor Commented:
Cheers, I have got the text to rotate. The cursor does change when the mouse hovers over the control but only part of it, any ideas?

I have also added code much the same as yours above to the mousedown and mouseup events to change the colour, but only the part of the label which doesn't change the mouse cursor changes colour. Again any ideas?
0
 
RonaldBiemansCommented:
Hi Zomby_dog,

Like I said in my previous comment that that is the problem with overwriting the paint, you will have to write your own linklabel control to accomodate that. Which could mean a lot of work.

Just a small question is there only one link in the label or are there more ?

If there is only one maybe I can write a quick workaround.

The reason you only get the mousepointer in a small area is the fact that it only takes into account the original text which was horizontal, so you only get the linkmousepointer in the original text, the same goes for the color
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now