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

Aug 13 2007 1:30 AM

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)