listBox1.SelectedItems.Remove和listBox1.Items.Remove有什麼區別?
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("當前沒有輸入內容", "提示");
}
else
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItems.Count == 0)
{
MessageBox.Show("當前沒有選擇內容", "提示");
}
else
{
//listBox1.SelectedItems.Remove(listBox1.SelectedItem);
listBox1.Items.Remove(listBox1.SelectedItem);
}
}
listBox1.Items.Remove(listBox1.SelectedItems[0]);