[求助]splitcontainer导致的重绘问题
我是直接在splitcontainer2.panel1里面直接绘制的网格,当我移动拆分线时,图形消失。(这个我想不懂,应该不会消失才对,觉得应该是panel2新出现的区域没有线条而已)请问怎么进行重绘,实现网格的放大缩小?protected override void OnPaint(PaintEventArgs pe)
{
// Call the OnPaint method of the base class.
base.OnPaint(pe);
Graphics g = Graphics.FromHwnd(this.splitContainer2.Panel1.Handle);
Pen p1 = new Pen(Color.SaddleBrown, 1);
int lineNo, lineNo2;
float linelocal, linelocal2;
for (lineNo = 1; lineNo <= 21; lineNo += 1)
{
linelocal = splitContainer2.Panel1.Height * lineNo / 22;
g.DrawLine(p1, 0, linelocal, splitContainer2.Panel1.Width + 1, linelocal);
}
for (lineNo2 = 1; lineNo2 <= (22 * splitContainer2.Panel1.Width / splitContainer2.Panel1.Height - 1); lineNo2 += 1)
{
linelocal2 = splitContainer2.Panel1.Height * lineNo2 / 22;
g.DrawLine(p1, linelocal2, 0, linelocal2, splitContainer2.Panel1.Height + 1);
}
SetStyle(ControlStyles.ResizeRedraw, true);
g.Dispose();
}