| | |
redrawing panel
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 27
Reputation:
Solved Threads: 0
I have a panel on form and i'm drawing a graph on it with a pen.When i open something on top of that form or i minimize the form and maximize it, the panel goes white until i draw something on it again.So i think i could call an event when my form goes inactive and active again or when i close anything that i have opened on top of that form.But my problem is that i don't know what should be a trigger for my event.Or if someone knows some better way!!!
Thanks!!!
Thanks!!!
•
•
Join Date: Feb 2008
Posts: 99
Reputation:
Solved Threads: 5
your description is a little bit confusing but let me guess: trigger the refresh() method for the form:
C# Syntax (Toggle Plain Text)
this.Refresh(); // for immediate redraw of the form and it's components
•
•
Join Date: Jul 2008
Posts: 27
Reputation:
Solved Threads: 0
•
•
•
•
your description is a little bit confusing but let me guess: trigger the refresh() method for the form:
C# Syntax (Toggle Plain Text)
this.Refresh(); // for immediate redraw of the form and it's components
I dont know what to use for triggering the event!!!
•
•
Join Date: Feb 2008
Posts: 99
Reputation:
Solved Threads: 5
for minimize/maximize try AutoSizeChanged event:
If you open other programs (windows) over the form i know what happenes. you can't do anything for that except 2 things i think:
1) try Activated event for the Focus of the form (because your form is not activated while you use other windows)
2) this really works but i's a little bit complicated. use a thread, BackgroundWorker to Refresh() you pannel. I can't tell the conde right now cause it's a little bit long. The problem is that if the thread refreshes the panel to at very little time intervals, the panel could flicker.
Hope at least one of these solution works.
C# Syntax (Toggle Plain Text)
private void Form1_AutoSizeChanged(object sender, EventArgs e) { this.Refresh(); }
1) try Activated event for the Focus of the form (because your form is not activated while you use other windows)
2) this really works but i's a little bit complicated. use a thread, BackgroundWorker to Refresh() you pannel. I can't tell the conde right now cause it's a little bit long. The problem is that if the thread refreshes the panel to at very little time intervals, the panel could flicker.
Hope at least one of these solution works.
•
•
Join Date: Feb 2008
Posts: 99
Reputation:
Solved Threads: 5
sorry in my post i didn't mean AutoSizeChanged event but SizeChanged event:
C# Syntax (Toggle Plain Text)
private void Form1_SizeChanged(object sender, EventArgs e) { this.Refresh(); }
•
•
Join Date: Jan 2009
Posts: 21
Reputation:
Solved Threads: 7
ddanbe, on the contrary, it wouldn't do an infinite loop like you are suspecting. From your post I'm guessing you're talking about putting a Form.Invalidate(); in the Paint Event, however I didn't suggest doing that. I had stated to invalidate the graphing object. Try it yourself. Create a blank form with a rich textbox. Then do invalidate on the rich textbox.
You will probably notice that only a few events come through (typically 3) when the form is focused. In my experience, the Paint event is only fired when the form object is painted, not the controls or objects within the form object. For example, if you make the form big and the rich textbox big, drag a small window over the rich textbox. You will notice that the Paint event is not firing. Next while dragging, just slightly move over a section of the form and the Paint event will fire.
This was why I suggested my path. Whatever object the graph is in, invalidate it from the Paint event of the form.
C# Syntax (Toggle Plain Text)
int x=0; private void Form1_Paint(object sender, PaintEventArgs e) { rtb1.Text += "x: "+(x++)+"\n"; rtb1.Invalidate(); }
You will probably notice that only a few events come through (typically 3) when the form is focused. In my experience, the Paint event is only fired when the form object is painted, not the controls or objects within the form object. For example, if you make the form big and the rich textbox big, drag a small window over the rich textbox. You will notice that the Paint event is not firing. Next while dragging, just slightly move over a section of the form and the Paint event will fire.
This was why I suggested my path. Whatever object the graph is in, invalidate it from the Paint event of the form.
Thanks for enlightning me on the subject. But.
I believe in most of the cases you are right.
Why is it that I get x:44 or x:32 from times to times, when I execute what you said?
I would like to produce the exact circumstances when I got those, (just shuffling windows)
Any ideas?
I believe in most of the cases you are right.
Why is it that I get x:44 or x:32 from times to times, when I execute what you said?
I would like to produce the exact circumstances when I got those, (just shuffling windows)
Any ideas?
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Other Threads in the C# Forum
- Previous Thread: Config.xml
- Next Thread: Advantages of C# over C++
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql nargalax networking object operator path photoshop picturebox pixelinversion polynomial post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






