这是我的代码
private void graphToolStripMenuItem_Click(object sender, EventArgs e)
{
button1.Visible = false;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
label1.Visible = false;
textBox1.Visible = false;
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
textBox9.Visible = false;
textBox10.Visible = false;
label2.Visible = false;
label3.Visible = false;
label4.Visible = true;
gg = this.CreateGraphics();
p3 = new Pen(Color.Blue,5);
b1 = new SolidBrush(Color.Red);
p2 = new Pen(Color.Red);
Font f=new Font("Arial",16);
float ox = this.ClientSize.Width / 2;
float oy = this.ClientSize.Height / 2;
gg.DrawLine(p3, ox - 500, oy, ox + 500, oy);
gg.DrawLine(p3, ox, oy + 300, ox, oy - 300);
gg.DrawString("Argument", f, b1, ox - 100, oy - 200);
gg.DrawString("<----f(Argument)---->", f, b1, ox + 100, oy + 100);
for (int i = 0; i < 1000; i++)
{
double tem1 = graphValuesCal();
double temp2 = functionCal();
gg.FillEllipse(b1, ox + (float)tem1/2,oy-20*(float)temp2, (float)5, (float)5);
Thread.Sleep(10);
}
}
当我运行此代码时,会绘制图表,但是当循环完成图表以及字符串和线条(轴)消失时。如果我注释掉这段代码
button1.Visible = false;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
label1.Visible = false;
textBox1.Visible = false;
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox7.Visible = false;
textBox8.Visible = false;
textBox9.Visible = false;
textBox10.Visible = false;
label2.Visible = false;
label3.Visible = false;
意味着如果所有这些控件之前都是可见的,那么当我单击该Graph menu
项目时它们将保持可见。然后线条和图表不会消失这里可能有一些基本的东西,但我想我错过了那个。需要帮助