日期:2014-05-18 浏览次数:20906 次
        private void Form1_Load(object sender, EventArgs e)
        {
            this.listBox1.Items.Add("zhangsan");
            this.listBox1.Items.Add("lisi");
            this.listBox1.Items.Add("wangwu");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.listBox1.SelectedIndex != -1)
            {
                MessageBox.Show("当前的选择是:" + this.listBox1.SelectedItem.ToString());
            }
            else
            {
                MessageBox.Show("还没选择");
            }
        }
------解决方案--------------------
if (this.listBox1.SelectedIndex != -1)
{
MessageBox.Show("当前的选择是:" + this.listBox1.SelectedItem.ToString());
}
else
{
MessageBox.Show("还没选择");
}