IT_Steve
asked on
When does the DrawString method fire?
I am trying to use the DrawString method to display data in a label. Why will it onlt display after I clock ok to my messagebox ? I want it to display on formload. Please check out my code example. I am using VB.NET 2003. Thank you.
' A font for the standard size text:
Dim fnt As Font = New Font("Microsoft Sans Serif", 8, FontStyle.Bold)
' A Brush to write the text:
Dim b As Brush = New SolidBrush(Color.Black)
' Graphics objects
Dim lgNH3 As Graphics = lblNH3.CreateGraphics
MessageBox.Show("HUH?")
Dim strNH As String = "What the..?"
lgNH3.DrawString(strNH, fnt, b, 1, 1)
' A font for the standard size text:
Dim fnt As Font = New Font("Microsoft Sans Serif", 8, FontStyle.Bold)
' A Brush to write the text:
Dim b As Brush = New SolidBrush(Color.Black)
' Graphics objects
Dim lgNH3 As Graphics = lblNH3.CreateGraphics
MessageBox.Show("HUH?")
Dim strNH As String = "What the..?"
lgNH3.DrawString(strNH, fnt, b, 1, 1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Because it is rare when CreateGraphics() should actually be used with a Control...since when the control refreshes itself, whatever you drew gets erased.
CreateGraphics() does not give you a persistent drawing surface.
CreateGraphics() does not give you a persistent drawing surface.
ASKER
Thank you for the explanation. The points are yours!
Steve
Steve
ASKER