回复 2# guang 的帖子
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace shap
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void sel_ch(object sender, EventArgs e)
{
switch (comboBox1.Text)
{
case "正方形":
{ label1.Text = "正方形的边长";
//a= Convert.ToInt32 (textBox1.Text);
label2.Visible = false;
textBox2.Visible = false;
label3.Visible = false;
textBox3.Visible = false;
break;
}
case "长方形":
{
label1.Text = "长方形的长";
//int a = Convert.ToInt32(textBox1.Text);
//int b = Convert.ToInt32(textBox2.Text);
label2.Text = "长方形的宽";
label2.Visible = true;
textBox2.Visible = true;
label3.Visible = false;
textBox3.Visible = false;
/*Graphics g = f.pictureBox1.CreateGraphics();
Pen pen = new Pen(Color.Red, 2);
g.DrawRectangle(pen, 10, 10, a, b);*/
break;
}
case"圆形":
{label1.Text = "圆形的半径";
label2.Visible = false;
textBox2.Visible = false;
label3.Visible = false;
textBox3.Visible = false;
break;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form2 f = new Form2();
f.ShowDialog();
f.Show();
Graphics g = f.pictureBox1.CreateGraphics();
Pen pen = new Pen(Color.Red, 2);
int a = Convert.ToInt32(textBox1.Text);
int b = Convert.ToInt32(textBox2.Text);
switch (comboBox1.Text)
{
case "正方形":
{
g.DrawRectangle(pen, 10, 10,a, a);
break;
}
case "长方形":
{
g.DrawRectangle(pen, 10, 10, a, b);
break;
}
case "圆":
{
g.DrawEllipse(pen, 10, 10, a, a);
break;
}
}
}
}
}帮忙看看。。。。