ComboBox SelectedIndexChanged event: how to get the previously selected index?

前端 未结 6 1083
闹比i
闹比i 2021-01-17 11:35

I have a user control which has a ComboBox and a SelectedIndexChanged event handler. In the event handler, I need to be able to tell what was the previously selected index.

6条回答
  •  梦毁少年i
    2021-01-17 11:55

    This one to get the current selected index ,I just need it and I couldn't find anywhere ,so I hope it helps

     private void lsbx_layers_SelectedIndexChanged(object sender, EventArgs e)
            {
                int i = lsbx_layers.SelectedIndices[0];//selected index
                MessageBox.Show("Selected item at index : " + i);
            }
    

提交回复
热议问题