473,386 Members | 1,668 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,386 software developers and data experts.

add an item to a listbox

Sam
Hi,
How can I add an item to a listbox so that when we select an item
afterward, we'll get the id associate, like the display member and the
value member for a combobox ?
regards

Nov 21 '05 #1
3 1388
Oh I think I can answer this one!

To add an item:
m_pListBox.Items.Add("Item 1")

To get the selected item:
Private Sub m_pListBox_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles m_pListBox.Click
Dim iIndex as Integer = m_pListBox.SelectedIndex
Dim o as Object = m_pListBox.Items(iIndex)
End Sub

Hope that answers your question.

Ryan

"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
How can I add an item to a listbox so that when we select an item
afterward, we'll get the id associate, like the display member and the
value member for a combobox ?
regards

Nov 21 '05 #2
this is for a combo but it should also work for listbox.

http://groups.google.be/group/micros...s.vb/msg/64c98
46f92012df6?hl=nl
greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Ryan Chavez" <rt******@hotmail.com> schreef in bericht
news:e3**************@TK2MSFTNGP10.phx.gbl...
Oh I think I can answer this one!

To add an item:
m_pListBox.Items.Add("Item 1")

To get the selected item:
Private Sub m_pListBox_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles m_pListBox.Click
Dim iIndex as Integer = m_pListBox.SelectedIndex
Dim o as Object = m_pListBox.Items(iIndex)
End Sub

Hope that answers your question.

Ryan

"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
How can I add an item to a listbox so that when we select an item
afterward, we'll get the id associate, like the display member and the
value member for a combobox ?
regards


Nov 21 '05 #3
Sam
That wasn't the question actually....
Anyway, this is what I wanted to do but it didn't work only because I
had a spell error in my valuemember field.... :(
lstFields.DataSource = m_dsCtrl.Tables(0)
lstFields.DisplayMember = "FieldName"
lstFields.ValueMember = "FieldID"

Nov 21 '05 #4

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

Similar topics

4
by: Peter Moscatt | last post by:
I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the...
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...
1
by: jez123456 | last post by:
Hi, I have a windows form with a listbox control. My code all works correctly when deleting an item from the listbox except the last item. I get the following message when trying to delete the...
6
by: orahm | last post by:
I added an object to a listbox. This object is a complex number and not a string so it shows "Consolapplication.Complex" as a list item. If I convert the complex number to a string then it shows a...
6
by: David De Cotis | last post by:
Hello all, I am trying to go through a ListBox and verify if am item was selected. If an item was selected, I would like to get a handle of the item and simply do a response.write on the selected...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
3
by: Dean Slindee | last post by:
In a checked listbox, I am allowing drag/drop of the items within (resequencing). Problem is, when dropping a checked item, the checked state always reverts to unchecked (unwanted). Anyone know...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
3
by: perrycheung221 | last post by:
Hi guys, I got 2 listboxes in a window form, one on left and one on right. The 1st listbox have some items while the 2nd listbox is empty. Also there are 2 buttons between the 2 listboxes which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.