ListBox Question #2

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

I have a listbox with the style set to dropdown. It has two items in it.
When the user selects the first item the code should do one thing if the
user selects another, do another thing. But how do I determine which value
the user selected? In which event do I place my code and what should it
look like?
 
Woody,
If it was a combobox the event selectedindexchanged
and dim myItem as string = combobox.selecteditem
Cor
 
I'm sorry. I think I must appear lazy sometimes. The answer to my question
is - place the following code in the SelectedInexChanged Event:

Dim str As String
str = SearchTreeCB1.SelectedItem.ToString()

Believe it or not the last 9 months have been months of almost continuous
study and review of various manuals and third party books related to VS and
SQL Server. Sometimes I get so much crammed into my brain that I simply
can't remember some of the fundamentals and so I ask short quick questions
on this forum. At least, I try to keep them short.

I came to VS from PowerBuilder and Adaptive Server Anywhere. These are both
robust tools and I thought I knew a little something when using them but
learning VS and SQL Server has taught me that I don't know as much as I
thought. The good and bad news about VS is that it does seem to have all
the tools you need for what ever you want to do. In fact, this, in a way,
is a draw-back too. You don't just have a list box or a combo box you also
have other choices that sometimes seem endless. At least you do when you
factor in other products like Infragistics. They have about six different
flavors of Listboxes or combo boxes or drop down boxes etc. All I am doing
are Winforms apps, not even thinking about the net. I find, however, that
the choices for a good interface are so many that it simply takes time to
get up on all the options. I would rather have them than not, but you get
the idea.

Thank you for your help and the help of others.
 
Hello,

Cor said:
If it was a combobox the event selectedindexchanged
and dim myItem as string = combobox.selecteditem

This works with the listbox too. Make sure you turn on "Option Strict".

;-)

Regards,
Herfried K. Wagner
 
Herfried,
Woody knows that see his answer to the line that Armin wrote:
I'm sorry. I think I must appear lazy sometimes. The answer to my question
is - place the following code in the SelectedInexChanged Event:

Dim str As String
str = SearchTreeCB1.SelectedItem.ToString()
Cor
 
Hello,

Cor said:
Woody knows that see his answer to the line that Armin wrote:
I'm sorry. I think I must appear lazy sometimes. The answer to my question
is - place the following code in the SelectedInexChanged Event:

Dim str As String
str = SearchTreeCB1.SelectedItem.ToString()

Always use "Option Strict On" if you are not a "god".

HTH,
Herfried K. Wagner
 
Back
Top