Re: About drawing something on a Control.

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



linuxfedora@xxxxxxxxxxxx wrote:
if i want to draw something on the control, then how can i do it?
For example, when i call function named WriteSomeThingOnPanel(),

Then there will be a line drawn on Panel?

I have tried to get the Graphics of the Panel by
Graphic.FromHwnd(panel.Handle);
then draw the line, but nothing can be drawn?Thanks


You use the Paint event, just as in the code that you posted. The event arguments contains a reference to the graphics object that should be used for drawing, just as in the code that you posted.

To trigger the Paint event, you call the Invalidate method on the control.

--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: Some basic graphic
    ... In the C-tor I try to draw a red line from location 1,1 with width 20 to ... location 100,100 but nothing is being drawn when the code is being ... I must say that graphics is very new to me so my knowledge is very ... It works now I didn't saw the paint event for the Form class the first time ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Drawing Lines On Panels
    ... > Panels have no Paint event, ... > And Panel cant give Graphics, nothing, except Form, can do that. ... >>int, int, int, int)) is currently supported directly through the CF. So if ...
    (microsoft.public.pocketpc.developer)
  • Saving image in picbox
    ... I used a picture box to draw lines and rectangle using its graphics ... object in paint event. ... Now i need to save those lines i have drawn and ...
    (microsoft.public.dotnet.languages.csharp)
  • how to draw sth on a Panel permanently?
    ... I need to draw sth to a Panel in an action, ... Graphics g = palCanvas.getGraphics; ... Yes, the polygon is drawn, but after I update any control in the same form ...
    (comp.lang.java.gui)
  • Re: How do I turn off write combining programatically?
    ... I should not bother with GDI+ and try the DirectX drawing stuff. ... I just do something like this in paint event ... ... Any exception thrown while drawing with a Graphics will tend to ... >> screensaver, and my posted sample in sheer disgust and destroy all source ...
    (microsoft.public.dotnet.framework.drawing)