473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ListBox Question #2

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?

Nov 20 '05 #1
5 1378
Cor
Woody,
If it was a combobox the event selectedindexchanged
and dim myItem as string = combobox.selecteditem
Cor
Nov 20 '05 #2
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.

Nov 20 '05 #3
Hello,

"Cor" <no*@non.com> schrieb:
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
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #4
Cor
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
Nov 20 '05 #5
Hello,

"Cor" <no*@non.com> schrieb:
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
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
3
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.