Mehdi,
Thank you so much! I wasn't very familiar with "Invalidate" but your
response lead me to a successful fix.
In case you're wondering, originally I had just one method to draw and erase
lines:
private void DrawSeparatorLine(Panel panel, int y, Color color)
{
Graphics g = panel.CreateGraphics();
Pen myPen = new Pen(color, 1);
g.DrawLine(myPen, 2, y, panel.ClientSize.Width - 2 , y); // Leave
2-pixel gap
g.Dispose();
}
But it wasn't working once I switched to gradient panels. To resolve the
problem I implemented a second method:
private void EraseSeparatorLine(Panel panel, int y)
{
Graphics g = panel.CreateGraphics();
Rectangle rect = new Rectangle(2, y, panel.ClientSize.Width - 2, 1);
panel.Invalidate(rect, false);
g.Dispose();
}
Though written for the general public, I even gave you credit on my blog:
http://pelalusa.blogspot.com/2006/05...can-be-so.html
Thank you again!
--
Robert W.
Vancouver, BC
www.mwtech.com
"Mehdi" wrote:
On Mon, 1 May 2006 18:34:02 -0700, Robert W. wrote:
In my WinForms app I'd long ago implemented a drag & drop mechanism just like
is used in PowerPoint when one wants to rearrange the order of the slides.
Specifically, a thin black line is shown between thumbnails to indicate where
an item will be dropped.
As the user moved away I'd erase it by simply drawing another line using the
BackColor of the panel. This worked great! But I've recently switched to
using a Gradient panel and so now the BackColor no longer applies.
Can anyone recommend how I should erase the thin black line?
It's not very clear how you've implemented the black line drawing (which
control is drawing it?). If the panel is drawing it, then calling its
Invalidate() method passing the appropriate rectangle will cause the panel
to redraw itself properly. If the drawing is made by the form, then call
the form's Invalidate() method passing the appropriate rectangle to force
it to redraw properly.