How to select an item in ListBox without firing SelectedIndexChang

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
a ListBbox is populated with 10 items. whenever the user selects an item in
the ListBox, some actions take place and eventually removes that selected
item from the ListBox and again displays the ListBox.

After deleting an item, I wish to highlight(selection) the next item below
it. After that, the ListBox has to be displayed. What I have to do for that?

Currently I am using the SelectedIndexChanged Event of ListBox. So whenever
i select the next item programatically, the further actions also happens as
if the user has selected another item.

Regards,
Hari
 
You could remove the eventhandler, programmatically select an item and then
reattach the event handler...

You could have a flag which you toggle before and after selecting an item
programmatically; in your event handler check for the flag and exit/return
as appropriate

I am sure there are other workarounds but any of the above will do...

Cheers
Daniel
 
Thank you so much Daniel

Daniel Moth said:
You could remove the eventhandler, programmatically select an item and then
reattach the event handler...

You could have a flag which you toggle before and after selecting an item
programmatically; in your event handler check for the flag and exit/return
as appropriate

I am sure there are other workarounds but any of the above will do...

Cheers
Daniel
 
Back
Top