Hey all,
I'm trying to write a method that is called from a variety of forms at load.
So with a Form1 load event I would call the following:
The DrawVerticalSTringFromBottomUp Method is as follows:Code:Dim testpoint As New Point(10, 20) DrawVerticalStringFromBottomUp("Hello", testpoint, Me)
When I call the code at a form's load event, nothing happens.Code:Public Sub DrawVerticalStringFromBottomUp(ByVal textToAdd As String, ByVal location As Point, ByVal callingForm As Form) ' Create the string to draw on the form. Dim text As String = textToAdd ' Create a GraphicsPath. Dim path As New System.Drawing.Drawing2D.GraphicsPath ' Add the string to the path; declare the font, font style, size, and ' vertical format for the string. path.AddString(text, callingForm.Font.FontFamily, 1, 10, New PointF(0.0F, 0.0F), _ New StringFormat(StringFormatFlags.DirectionVertical)) ' Declare a matrix that will be used to rotate the text. Dim rotateMatrix As New System.Drawing.Drawing2D.Matrix ' Set the rotation angle and starting point for the text. rotateMatrix.RotateAt(180.0F, location) ' Transform the text with the matrix. path.Transform(rotateMatrix) With callingForm.CreateGraphics .SmoothingMode = Drawing2D.SmoothingMode.HighQuality .FillPath(Brushes.Black, path) End With ' Dispose of the path. path.Dispose() End Sub
When I call it from a button click after the form has loaded it works!
I know this should be called from the paint method, but that doesn't suit my purposes.
Can anyone suggest a way to make this work from the form load event?
Thanks!
Nick




Reply With Quote