Drawlines on different levels
-
Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?
Alex
-
Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?
Alex
I think this[^] should help you. :)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?
Alex
Your problem is probably caused by not doing all of your drawing in the Panel's Paint event. Do NOT create your own graphics object. Use the one that Windows hands you in the event args of the Paint event.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Hi, sorry for my bud English. I have to draw up an Forms.panel using a "Graphics" object (objPanel.CreateGraphics). I uploaded my design (graphic DrawLine) and I would "fizzle" because I run this graph by drawing a vertical line near the mouse pointer. Mine is a refresh problem because scrolling the mouse leave the previous vertical lines. I tried with "invalidate (rect)" but I do not redraw the chart below. Can you help me with an example? Is 'possible "to fizz" below the others drawlines and draw on a higher level without losing low level?
Alex
Drawing a grid on a panel? I just did that a little while ago. Here's a sample that makes a 20-px grid.
private Pen pen = new Pen(Color.FromArgb(60, 60, 60), 1);
private void something_Paint(object sender, PaintEventArgs e)
{
for (int x = 20; x < Width; x += 20) e.Graphics.DrawLine(pen, x, 0, x, Height);
for (int y = 20; y < Height; y += 20) e.Graphics.DrawLine(pen, 0, y, Width, y);
}[Edit]: Moved Pen object out of method.
-
Drawing a grid on a panel? I just did that a little while ago. Here's a sample that makes a 20-px grid.
private Pen pen = new Pen(Color.FromArgb(60, 60, 60), 1);
private void something_Paint(object sender, PaintEventArgs e)
{
for (int x = 20; x < Width; x += 20) e.Graphics.DrawLine(pen, x, 0, x, Height);
for (int y = 20; y < Height; y += 20) e.Graphics.DrawLine(pen, 0, y, Width, y);
}[Edit]: Moved Pen object out of method.
You forgot to Dispose the Pen. Nothing like an example that leaks GDI resources!
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
You forgot to Dispose the Pen. Nothing like an example that leaks GDI resources!
A guide to posting questions on CodeProject[^]
Dave KreskowiakOr even better, don't re-create it on every Paint in the first place. Moved it out of the method. :-D
-
I think this[^] should help you. :)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
Your problem is probably caused by not doing all of your drawing in the Panel's Paint event. Do NOT create your own graphics object. Use the one that Windows hands you in the event args of the Paint event.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Or even better, don't re-create it on every Paint in the first place. Moved it out of the method. :-D
-
I think this[^] should help you. :)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
You're welcome. :)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.