窗口应用设计
作者:互联网
Form2
private void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked && checkBox3.Checked && !checkBox2.Checked && !checkBox4.Checked)
MessageBox.Show("您答对了,真的很棒!!!", "信息提示", MessageBoxButtons.OK);
else
MessageBox.Show("您答错了,继续努力吧", "信息提示", MessageBoxButtons.OK);
}
Form3
private void button1_Click(object sender, EventArgs e)
{
if (radioButton3.Checked)
MessageBox.Show("您选对了,这是微软公司开发的操作系统","信息提示", MessageBoxButtons.OK);
else if (radioButton1.Checked || radioButton4.Checked)
MessageBox.Show("您选错了,这是程序设计语言", "信息提示", MessageBoxButtons.OK);
else
MessageBox.Show("您选错了,这是数据库管理系统", "信息提示", MessageBoxButtons.OK);
}
Form4
private void button1_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("SPRING.jpg");
}
private void button2_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("SUMMER.jpg");
}
private void button3_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("FALL.jpg");
}
private void button4_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("WINTER.jpg");
}
Form5
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
if (!comboBox1.Items.Contains(textBox1.Text))
comboBox1.Items.Add(textBox1.Text); //不添加重复项
}
Form6
private void Form7_Load(object sender, EventArgs e)
{
listBox1.Items.Add("清华大学");
listBox1.Items.Add("北京大学");
listBox1.Items.Add("浙江大学");
listBox1.Items.Add("南京大学");
listBox1.Items.Add("武汉大学");
listBox1.Items.Add("中国科技大学");
listBox1.Items.Add("中国人民大学");
listBox1.Items.Add("华中科技大学");
listBox1.Items.Add("复旦大学");
enbutton(); //调用enbutton()方法
}
private void enbutton() //自定义方法
{
if (listBox1.Items.Count == 0)
{
button1.Enabled = false;
button2.Enabled = false;
}
else
{
button1.Enabled = true;
button2.Enabled = true;
}
if (listBox2.Items.Count == 0)
{
button3.Enabled = false;
button4.Enabled = false;
}
else
{
button3.Enabled = true;
button4.Enabled = true;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex >= 0)
{
listBox2.Items.Add(listBox1.SelectedItem);
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
enbutton();
}
private void button2_Click(object sender, EventArgs e)
{
foreach (object item in listBox1.Items)
listBox2.Items.Add(item);
listBox1.Items.Clear();
enbutton();
}
private void button3_Click(object sender, EventArgs e)
{
if (listBox2.SelectedIndex >= 0)
{
listBox1.Items.Add(listBox2.SelectedItem);
listBox2.Items.RemoveAt(listBox2.SelectedIndex);
}
enbutton();
}
private void button4_Click(object sender, EventArgs e)
{
foreach (object item in listBox2.Items)
listBox1.Items.Add(item);
listBox2.Items.Clear();
enbutton();
}
Form7
private void Form8_Load(object sender, EventArgs e)
{
checkedListBox1.Items.Add("中国");
checkedListBox1.Items.Add("美国");
checkedListBox1.Items.Add("俄罗斯");
checkedListBox1.Items.Add("英国");
checkedListBox1.Items.Add("法国");
checkedListBox1.CheckOnClick = true;
}
private void button1_Click(object sender, EventArgs e)
{
foreach(object item in checkedListBox1.CheckedItems)
listBox1.Items.Add(item);
}
标签:窗口,listBox1,Items,void,object,private,Add,应用,设计 来源: https://blog.csdn.net/qq_55080421/article/details/122105514