I tried the both
In onPaint event (on mainForm and every one of controls) is does not seemed
to help. Invocation of Invalidate function CLEARS all graphics drawn
Follow the code of drawing I do
private void drawCant(TSComponents.TSTabButton button)
{
//this.Invalidate();
//this.Refresh();
Graphics gr_Middle = this.pnlMiddle.CreateGraphics();
Graphics gr_Down = this.pnlDown.CreateGraphics();
gr_Middle.Clear(this.pnlMiddle.BackColor);
gr_Down.Clear(this.pnlDown.BackColor);
Pen p = new Pen(button.ForeColorClick,2);
Point[] pts_Middle =
{
new Point(button.Location.X+2,0),
new Point(2,2),
new Point(2,pnlMiddle.Height),
new Point(pnlMiddle.Width-2,pnlMiddle.Height),
new Point(pnlMiddle.Width-2,2),
new Point(button.Location.X+button.Width-2,2),
new Point(button.Location.X+button.Width-2,0)
};
Point[] pts_Down =
{
new Point(button.Location.X+2,0),
new Point(button.Location.X+2,2),
new Point(2,2),
new Point(2,pnlDown.Height-2),
new Point(pnlDown.Width-2,pnlDown.Height-2),
new Point(pnlDown.Width-2,2),
new Point(button.Location.X+button.Width-2,2),
new Point(button.Location.X+button.Width-2,0)
};
Point[] pts_Down_Alone =
{
//new Point(button.Location.X+2,0),
//new Point(button.Location.X+2,2),
new Point(2,0),
new Point(2,pnlDown.Height-2),
new Point(pnlDown.Width-2,pnlDown.Height-2),
new Point(pnlDown.Width-2,0),
//new Point(button.Location.X+button.Width-2,2),
//new Point(button.Location.X+button.Width-2,0)
};
if (pnlMiddle.Visible)
gr_Middle.DrawLines(p,pts_Middle);
if(pnlMiddle.Visible)
gr_Down.DrawLines(p,pts_Down_Alone);
else
gr_Down.DrawLines(p,pts_Down);
gr_Middle.Dispose();
gr_Down.Dispose();
//this.pnlMiddle.Invalidate();
//this.pnlDown.Invalidate();
}
"Jeffrey Tan[MSFT]" said:
Hi Tamir,
Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.
Based on my understanding, you want to show graphics that was created out
using Control.CreateGraphics well in WinForm.
==============================================
Based on my experience, when your control loses focus or being clicked, the
Paint event will fires. So I think if you invoke your
Control.CreateGraphics code in the control's Paint event, your graphics
will not disappear.
Also, if in some event, your control does not paint well, you can
explicitly call the Control.Invalidate method to force the control to
repaint.
If it still does not work, please paste some sample code, I will work with
you.
==============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.