RE: Problems drawing GDI+ text
- From: v-lliu@xxxxxxxxxxxxxxxxxxxx (Linda Liu[MSFT])
- Date: Mon, 21 Apr 2008 05:43:05 GMT
Thanks Jack for your reply!
Hi Bob,
What Jack has explained and suggested is correct.
You should draw the text in the Paint event handler of the Panel. When you
need to draw a new text in the Panel, just call the Invalidate method of
the Panel to get the Panel to redraw itself.
The following is a sample:
Public Class Form1
Private font As Font = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
font = New Font("Arial", 18, FontStyle.Regular)
End Sub
Private myText As String = ""
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
myText = Me.TextBox1.Text
Me.Panel1.Invalidate()
End Sub
' Every time the Panel redraws itself, it draw all strings
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
e.Graphics.DrawString("existing string", font, Brushes.Black, 0, 0)
If (Not myText.Equals("")) Then
e.Graphics.DrawString(myText, font, Brushes.Black, 0, 20)
End If
End Sub
End Class
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: Problems drawing GDI+ text
- From: Bob Altman
- Re: Problems drawing GDI+ text
- References:
- Problems drawing GDI+ text
- From: Bob Altman
- Problems drawing GDI+ text
- Prev by Date: Re: Problems drawing GDI+ text
- Next by Date: Re: Problems drawing GDI+ text
- Previous by thread: Re: Problems drawing GDI+ text
- Next by thread: Re: Problems drawing GDI+ text
- Index(es):
Relevant Pages
|