Drawing And Resized Forms

S

sternr

Hey,
I have a simple Win Forms that draws a line (graphics.drawLine) on the
current form,
All is well until the user resizes the form - after the resize,
When I draw a line on a part of the form that was not visible befure
the resize,
It does nothing! I mean I get no exception but it doesnt draw the line!
Any suggestions?
Thanks ahead

--sternr
 
N

Nicholas Paldino [.NET/C# MVP]

Sternr,

Where are you executing the code to draw the line? My guess is that it
is not in the OnPaint method of the form, or in an event handler for the
Paint event.

The reason this doesn't work is that programs with a UI in Windows have
a message pump. This is basically a while loop that gets messages from the
OS, and then performs an action based on that message. Being notified to
paint itself is one of those messages.

If you are not overriding the OnPaint method, or adding an event handler
to the Paint event and performing your drawing there, then when the form is
told to repaint itself, it has no clue that a line should be there, and then
erases what you had already painted.

Hope this helps.
 
S

sternr

Hey Nicholas tahnks for your reply!
You misunderstood me - when I enlarge my form all the lines I drew are
still visible,
The problem is, I'm trying to draw a link in a part of the form that is
visible only after the enlargment, and nothing happens...
Any idea?
Thanks ahead,

--sternr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top