I see two options.
The first is what I said in my comment.. invalidate the form to cause OnPaint
to be recalled after the drag drop:
foreach (string path in filePath)
{
// your other code here (PS: Paste code next time)
}
this.Invalidate();
Your other option.. is to use a flag that you can check in OnPaint
:
bool canDraw = false;
// dragdrop event:
foreach (string path in filePath)
{
// your other code here (PS: Paste code next time)
}
canDraw = true;
// OnPaint:
if (canDraw) {
// do your painting here
canDraw = false;
}
base.OnPaint(e); // make sure you defer to the base painting method too
The second option effectively delays your painting until you say its okay.. but only your custom painting. You leave the base.OnPaint
call out of your conditional so that it can always paint when it needs to.