在 picturebox画线为什么显示不出来(i是控制线的不同位置)
e.Graphics.DrawLine(new Pen(Color.Black,5 ), new Point(this.pBx_bjl .Location .X + (this.pBx .Width +66)*(i-1), this.pBx_bjl .Location .Y ), new Point(this.pBx_bjl .Location .X + (this.pBx .Width +66)*(i-1) ,85 ));
断点跟踪里面的point都有数据,但是为什么显示不出来,可能出现什么问题
e.Graphics.DrawLine(new Pen(Color.Black,5 ), new Point(this.pBx_bjl .Location .X + (this.pBx .Width +66)*(i-1), this.pBx_bjl .Location .Y ), new Point(this.pBx_bjl .Location .X + (this.pBx .Width +66)*(i-1) ,85 ));
断点跟踪里面的point都有数据,但是为什么显示不出来,可能出现什么问题
别用e.Graphics.DrawLine(.....),这样写试试:
Graphics g = picturebox.CreateGraphics();
g.DrawLine(.....);
private void pBx_bjl_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{ e.Graphics.DrawLine(new Pen(Color.Black,5 ), new Point(this.pBx_bjl .Location .X + (this.pBx .Width +66)*(i-1), this.pBx_bjl .Location .Y ), new Point(this.pBx_bjl .Location .X + (this.pBx .Width +66)*(i-1) ,85 ));
}
}
}在paint事件中写的,我都测到坐标都有数值,但是就是画不上,我测了2个小时也没有解决,郁闷死了
我在Form中还的写重绘么,是不是我的picturebox放在了一个panel中,被覆盖了,我如果要在panel的Paint中写就可以画出来,