2
Answers

How to get focus back to the Item in the ListBox.

Rajesh Sawant

Rajesh Sawant

17y
2.5k
1

Dear All,

When I remove Item from a delete command button,
Item gets removed, But focus is not back to the Next or Previous
(depending on deleted Item) Item of list box.

My code is as follows

private void cmdDelete_Click(object sender, EventArgs e)
{
int selectedIndex = this.ListBox.SelectedIndex;
if (selectedIndex != -1)
{
this.ListBox.tems.RemoveAt(selectedIndex);
this.ListBox.Focus();
}
}

 

Thanks

Redgs

Answers (2)