J
jcrouse
I am rotating some text is some label controls. In the one place I use it it
works fine. In the other place I use it I can't figure out the syntax. I
don't really understand the event. Where it works fine, it seems to fire
when the form changes visibility. Here is the code.
Private Sub lblP1JoyUp_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles lblP1JoyUp.Paint
If lblP1JoyUp.Visible = True Then
Dim myFontBrush As New SolidBrush(lblP1JoyUp.ForeColor)
If frm1.intPriHP1 = frm1.intPriVP1 Then
If strLay1RotAngle = "90" Then
Dim y As Integer =
CInt(e.Graphics.MeasureString(Label1.Text, lblP1JoyUp.Font).Width)
Dim x As Integer =
CInt(e.Graphics.MeasureString(Label1.Text, lblP1JoyUp.Font).Height)
lblP1JoyUp.Text = ""
e.Graphics.TranslateTransform((lblP1JoyUp.ClientSize.Width +
x) \ 2, (lblP1JoyUp.ClientSize.Height + y) \ 2)
e.Graphics.RotateTransform(90)
e.Graphics.DrawString(Label1.Text, lblP1JoyUp.Font,
myFontBrush, -y, 0)
End If
myFontBrush.Dispose()
End If
End Sub
However, I now also need to place the same type code under a control event
such as a button click event. I am struggling trying to figure out the
syntax, mostly the "ByVal e" part and the handler. What would the proper
syntax be to either place the above syntax under a button click event, or
better yet, maybe inside a sub of its own. I need to call the above code for
30 label controls so having it in it's own sub would probably be the way to
go, right?
Help,
John
works fine. In the other place I use it I can't figure out the syntax. I
don't really understand the event. Where it works fine, it seems to fire
when the form changes visibility. Here is the code.
Private Sub lblP1JoyUp_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles lblP1JoyUp.Paint
If lblP1JoyUp.Visible = True Then
Dim myFontBrush As New SolidBrush(lblP1JoyUp.ForeColor)
If frm1.intPriHP1 = frm1.intPriVP1 Then
If strLay1RotAngle = "90" Then
Dim y As Integer =
CInt(e.Graphics.MeasureString(Label1.Text, lblP1JoyUp.Font).Width)
Dim x As Integer =
CInt(e.Graphics.MeasureString(Label1.Text, lblP1JoyUp.Font).Height)
lblP1JoyUp.Text = ""
e.Graphics.TranslateTransform((lblP1JoyUp.ClientSize.Width +
x) \ 2, (lblP1JoyUp.ClientSize.Height + y) \ 2)
e.Graphics.RotateTransform(90)
e.Graphics.DrawString(Label1.Text, lblP1JoyUp.Font,
myFontBrush, -y, 0)
End If
myFontBrush.Dispose()
End If
End Sub
However, I now also need to place the same type code under a control event
such as a button click event. I am struggling trying to figure out the
syntax, mostly the "ByVal e" part and the handler. What would the proper
syntax be to either place the above syntax under a button click event, or
better yet, maybe inside a sub of its own. I need to call the above code for
30 label controls so having it in it's own sub would probably be the way to
go, right?
Help,
John