我在一个Form中的Label上画了了一个小图案
Graphics gh = label12.CreateGraphics();
Pen pe = new Pen(Color.Black, 1);
x = 23;
y = 15;
gh.DrawLine(pe, x-8, y-6, x+8, y+6);
gh.DrawLine(pe, x-8, y+6, x+8, y-6);
问题是这段代码要放在哪里好?
我放在Load、Activated、Shown事件中都没有达到效果
放在Paint事件中...
private void label1_Paint(object sender, PaintEventArgs e)
{
Graphics gh = e.Graphics;
Pen pe = new Pen(Color.Black, 3);
int x = 23;
int y = 15;
gh.DrawLine(pe, x - 8, y - 6, x + 8, y + 6);
gh.DrawLine(pe, x - 8, y + 6, x + 8, y - 6);
}
用楼上说的这个方法,然后还有一个方法叫做control.refresh();这样就能触发了