列表與索引

索引從0到3(圖中1-4)與列表對應
索引高于列表
列表刪除的時候需要依照索引
假設刪除3,后面的4頂上,列表中再刪4,就會報錯
優(yōu)先刪列表
不然就會報錯了
private void button6_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? //當前選中項目的索引
? ? ? ? ? ? int index = listBox1.SelectedIndex;
? ? ? ? ? ? //清空索引,不然多選會影響
? ? ? ? ? ? listBox1.SelectedIndices.Clear();
湊字數(shù)的代碼
標簽: