views:

115

answers:

2

I have a form in which i paint a waveform on a button click that is as soon as i click button, the waveform displays. Now when i minimize the form and maximize it again, the waveform disappears.How to repaint it? I have seen people using paint event but i dont know how to use it after/inside the button click event. Please help.

A: 

If you call Control.Invalidate(), the Paint event will occur.

deltreme
How to use it and where? please if you can elaborate.
gn
Windows automatically invalidates an area whenever it thinks it needs to be redrawn. It then sends notifications to the window(s) occupying that area on the screen, indicating they should re-paint the area. In .NET, this means the Paint event occurs.By calling Invalidate() on your control, you are manually telling Windows to send these notifications to your application.
deltreme
You can call Invalidate() anywhere in your code, even multiple times before the Paint event occurs. It will just mark your control as "dirty"; you don't have to worry about calling the Paint event manually.
deltreme
A: 

How are you drawing the waveform in the click event? Are you drawing on a panel? If you are calling CreateGraphics to get a graphics instance, then anytime your form is minimized or if another form covers up your form, your drawing will be lost.

Check this site:

http://bobpowell.net

and this article in particular:

http://www.bobpowell.net/picturebox.htm

Chris Dunaway