Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2006

Tip: Looking for answers? Try searching our database.

Text written with TextRenderer overwritten by other Controls?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim S - 08 Aug 2006 20:00 GMT
Hi everyone.

I'm trying to write text to a Windows Form with TextRenderer.Drawtext,
and it works fine - until I select an item from the Menu
(System.Windows.Forms.MenuStrip) above it - at which point any text in
the Form area underneath where the menu drops down gets erased.

Here's the code I'm using to write to the Form - from a method within my
Form class:

    Graphics g = this.CreateGraphics();
    TextRenderer.DrawText(g, "Some Text", this.Font, new Point(10,                50),
SystemColors.WindowText, TextFormatFlags.Default);

If I put a Text Control on the form at design time in VS05, that Text
Control DOESN'T get overwritten.

So, text that I'm adding manually at runtime with TextRenderer appear
but gets stomped on by other Controls, while Controls (eg: TextControl)
added at design time are preserved.

Any ideas?  I'm stumped and assume there's something that I need to call
in terms of Suspending Layout or Resuming or something like that, but no
idea what.

Thanks for any/all help!

- J
Kevin Spencer - 08 Aug 2006 20:45 GMT
Where is this code? It should be in the OnPaint method.

Signature

HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Expect the unaccepted.

> Hi everyone.
>
[quoted text clipped - 24 lines]
>
> - J

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.