- 博客(0)
- 资源 (2)
空空如也
优秀班委选举
优秀班委选举系统
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 优秀班委选举
{
public partial class Form1 : Form
{
private ListBox listBox;
public Form1()
{
InitializeComponent();
}
public Form1(ListBox listBox)
{
InitializeComponent();
this.listBox = listBox;
}
private void button1_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0)
{
if (listBox1.SelectedItem == null)
{
MessageBox.Show("请先选择一个对象!");
}
else
{
//获取左边listBox1中选中的内容
string cont = listBox1.SelectedItem.ToString();
//左边listBox1中删除选中的内容
listBox1.Items.Remove(cont);
//把获得的内容加入到右边的listBox2中
listBox2.Items.Add(cont);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (listBox2.Items.Count > 0)
{
if (listBox2.SelectedItem == null)
{
MessageBox.Show("请先选择一个对象!");
}
else
{
//获取右边listBox2中选中的内容
string cont = listBox2.SelectedItem.ToString();
//右边listBox2中删除选中的内容
listBox2.Items.Remove(cont);
//把获得的内容加入到左边的listBox1中
listBox1.Items.Add(cont);
}
}
}
//退出
private void button5_Click(object sender, EventArgs e)
{
Application.Exit();
}
//显示结果
private void button4_Click(object sender, EventArgs e)
{
//传递listBox2到Form2窗口中
Form2 form2 = new Form2(listBox2);
form2.Show();
}
//修改名单
private void button3_Click(object sender, EventArgs e)
{
if (listBox2.SelectedItem == null)
{
MessageBox.Show("请先选择一个对象!");
}
else
{
string cont = listBox2.SelectedItem.ToString();
int index = listBox2.SelectedIndex;
Form3 form3 = new Form3(cont, index, listBox2);
form3.Show();
this.Hide();
}
}
//加载窗口
private void Form1_Load(object sender, EventArgs e)
{
if (listBox != null)
{
foreach (string str in listBox.Items)
{
listBox2.Items.Add(str);
}
}
}
}
}
2014-03-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人