Take Action When Item Selected in Combo

  • Thread starter Robert A. Boudra
  • Start date
R

Robert A. Boudra

As a newcomer to .Net I'm continually frustrated with the subtle and not so
subtle changes that have been made since VB 6.0 that don't seem to server
any real purpose other than to frustrate people like me. In any case, I'm
trying to do something as simple as take an action when the user selects an
item from a combo box. I've tried using the SelectedIndexChange event, but
that fires several times while the list is being populated etc. before the
form is even visible. The work around that I came up with is to set a
boolean flag when the user first clicks the control so that the desired
action in the SelectedIndexChange event is only taken after the control has
been clicked by the user. This seems like an ugly solution to me. Is there
a better way?

Bob
 
C

Charlie Smith

Robert A. Boudra said:
I've tried using the SelectedIndexChange event, but
that fires several times while the list is being populated etc. before the

Bob,

I have dealt with this issue by declaring "private mLoaded as
Boolean=False" at the class level then surrounding the
"SelectedIndexChanged" event action with "if mLoaded then..." It
isn't very elegant (you have to set mLoaded to true after your object
initialization code) but it is effective.

I have also learned that there are better approaches for some objects,
but I am not aware of one for the Combobox. Perhaps one of the more
knowledgeable regulars here can provide a better answer.

Charlie
 

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