Re: Drawing in a user control



You seem to be suffering from the classic problem of one who is trying to
resolve message driven architecture with an encapsulated window.

You should set boolean variables at the class level to state whether or not
the particular drawing should take place and ONLY draw in the OnPaint
override.

You should also consider whether UserControl is the correct base class or
whether Control or ScrollableControl is a better base.

Ah, also NEVER create a control that handles it's own events.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





<feripar@xxxxxxxxx> wrote in message
news:1148761288.551983.121160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello!
I am creating a user control with several methods, each method should
draw something in my user control; from a winform, I should use:
myControl.ShowBands or myControl.ShowLabels, etc.; but I don't know how
to do that, because all the logic to draw should be in the Paint event,
but each method does very differents things. I tried to create all the
methods I need, but I don't have the Graphics reference. SO, my
question is how can I draw different things, using my custom methods
using the correct Graphics object.



Thanks,
Fernando.



.



Relevant Pages

  • Re: Hotspots in graphic
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > What is the best way to draw that image on the screen? ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Hotspots in graphic
    ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... > What is the best way to draw that image on the screen? ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Panel with Close button custom control
    ... Just create a user control with the button on it that you want. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... The panel never closes, the close button click event closes the form not ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Problems with a Image
    ... and then exportting that image to the response stream. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... > i have a problem when i want to draw, only, a part of an image. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Inside PictureBox questions
    ... PictureBox is for drawing images with.... ... > Find great Windows Forms articles in Windows Forms Tips and Tricks ... The statement that you can draw on ...
    (microsoft.public.dotnet.framework.drawing)