我想在另一个类的选项卡中的一个面板上绘制一些行,这些面板属于Form1 我试图传递Form1,面板参数,我可以绘制我想要的,但是当类绘制方法完成时,如果我从我的UI交换制表符,图纸就不见了......
Form1按钮;
private void button1_Click(object sender, EventArgs e)
{
panel1 = new Class1().Graph_set_axis(panel1);
}
class1方法;
public Panel Graph_set_axis(Panel _local)
{
Pen pen = new Pen(Color.Black, 2);
Point Origin = new Point(0, 0);
Point A = new Point();
Point B = new Point();
Graphics G = _local.CreateGraphics();
G.TranslateTransform(0, _local.Height);
G.ScaleTransform(1.0F, -1.0F);
A.X = 0;
A.Y = _local.Height;
B.X = _local.Width;
B.Y = 0;
G.DrawLine(pen, Origin, A);
G.DrawLine(pen, Origin, B);
int Y_units;
int X_units;
// int i = 1;
Y_units = _local.Height / 30;
for (int i = 0; i * Y_units < _local.Height; i++)
{
A.X = 0;
A.Y = i * Y_units;
B.X = A.X + 5;
B.Y = A.Y;
G.DrawLine(pen, A, B);
}
X_units = _local.Width / 30;
for (int i = 0; i * X_units < _local.Width; i++)
{
A.X = i * X_units;
A.Y = 0;
B.X = A.X;
B.Y = A.Y + 5;
G.DrawLine(pen, A, B);
}
return _local;
}
我需要在panel1上设置一个参数来保存其图纸吗?
由于