RE: Problems drawing GDI+ text

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • RE: Install font from ClickOnce application
    ... the system fonts folder and p/invokes win32 AddFontResource API to register ... registered font yet. ... Private Sub Button1_Click(ByVal sender As System.Object, ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework)
  • Re: Virtual Hosting Control Panel
    ... I spent a day trying to figure out why Horde failed to install the database properly. ... After a lengthy back and forth with their support it was finally told that their Makefile for two particular ports. ... We actually produce an in house RedHat/FreeBSD based panel called easyADMIN which allows a lot of flexibility in administration. ... Where it may not have the same pretty look as Plesk or the other big boys (ensim, cpanel) it makes up for in ease of administration from the web panel and the ability to further tune and expand upon it. ...
    (freebsd-questions)
  • RE: Update panel with Gridview control
    ... separate panel) on the page. ... Microsoft MSDN Online Support Lead ... Format of the initialization string does not conform ... connectionString, Int32 currentPosition, StringBuilder buffer, Boolean ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Asp.Net AJAX dynamically added Tab Control not displaying
    ... I am slowly getting to grips with the lifecycle, ... My final aim is to add the control within the Accordion custom control that ... tab panel within the ContentUserControl. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Filling Station
    ... Try fitting any MS font on a sign of a given dimension such as a sign ... panel in a plastic kit and the letters won't fit. ... a letter over the edge or you have too small lettering for the panel. ... Could you use mspaint and use the lettering tool to write your text then shrink the image to the size needed to fit the kit. ...
    (rec.models.railroad)