Pen p = new Pen(Color.Red, 1);
Point p1=...;
Point p2=...;
Graphics gr;
gr.DrawLine(p,p1,p2);
为什么总提示:使用了未赋值的局部变量“gr”
我用了gr=this.CreateGraphics();
但会要求创建:
private Graphics CreateGraphics()
{
throw new Exception("The method or operation is not implemented.");
}
难道因为我重写了redraw?
我现在就想画这个线,怎么画?
...全文
33026打赏收藏
Graphics DrawLine
Pen p = new Pen(Color.Red, 1); Point p1=...; Point p2=...; Graphics gr; gr.DrawLine(p,p1,p2); 为什么总提示:使用了未赋值的局部变量“gr” 我用了gr=this.CreateGraphics(); 但会要求创建: private Graphics CreateGraphics() { throw new Exception("The method or operation is not implemen
public class Class1
{
public void a()
{
Graphics gr;
Pen myPen = new Pen(Color.Red, 2);
Form1 s = new Form1();
gr = Graphics.FromHwnd(s.Handle);
gr.DrawLine(myPen, 30, 60, 150, 60);
我要怎么画到别的窗体上?
[/Quote]
Form2 f2 = new Form2();
IntPtr i = f2.Handle;
Graphics g = Graphics.FromHwnd(i);
Pen p = new Pen(Color.Red, 1);
Point p1=...;
Point p2=...;
g.DrawLine(p,p1,p2);