listbox events

G

Guest

Hey all,

I noticed that the listbox event "SelectedIndex_Changed" runs on form load
by default. Is there a way to by pass this until you actually have data in it
and are ready for selected index change event in your code or am I missing
the point?

thanks in advance,
rodchar
 
I

Imran Koradia

Are you sure? Just to make sure, I tested it out and it does not fire the
SelectedIndex_Changed event on the listbox. Are you setting the
SelectedIndex or SelectedItem property (or calling the Select method) in the
form load? Only then the event would be fired.


Imran.
 
B

Brian Henry

if your listbox is databound, the index will change on filling a dataset...
the best thing to do in that case is to set a flag when its filling so you
can check that flag in the selected index changed event to see if the index
is changing while its filling or not to prevent execution of the event while
that is happening
 
G

Guest

Thank you, this helped.

Brian Henry said:
if your listbox is databound, the index will change on filling a dataset...
the best thing to do in that case is to set a flag when its filling so you
can check that flag in the selected index changed event to see if the index
is changing while its filling or not to prevent execution of the event while
that is happening
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top