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

Combobox ItemData ?

In VB6 in combobox you can use ItemData to assign a key to the combo box
item.
Like so:
With cboGroup
.AddItem "Database"
.ItemData(.newindex) = c_RefData
:

I understand in VB.NET there is no equivalent for ItemData. So, if I need to
assign a key to the combobox item, how can I do that ?
Thank you.

Aug 9 '07 #1
1 7039
On Aug 9, 1:28 pm, "fniles" <fni...@pfmail.comwrote:
In VB6 in combobox you can use ItemData to assign a key to the combo box
item.
Like so:
With cboGroup
.AddItem "Database"
.ItemData(.newindex) = c_RefData
:

I understand in VB.NET there is no equivalent for ItemData. So, if I need to
assign a key to the combobox item, how can I do that ?
Thank you.
The VB.NET combobox is not limited to a strings with a Long value for
the .ItemData. You can store whole objects in the .net combobox:

public class TheDataItem
...
public property Name() as string
...
end property
public property Id () as integer
...
end property
...
end class

dim dataItem as new TheDataItem()
dataitem.name = "john"
dataitem.id = 123
combobox.displaymemeber = "Name"
combobox.items.add(dataitem)

HTH,
Tom Shelton

Aug 9 '07 #2

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

Similar topics

6
by: Mendhak | last post by:
Hi All, When you add an object to a combobox, and run the application, you'll get something like this: System.Windows.Forms.Button, Text: Button1 (for example). Is it possible to have...
4
by: Georges Heinesch | last post by:
Hi. I have a combobox with a value list of 4 items. My code needs to know the number of items in that combobox. How can I use VBA to get the number of items in a combobox? TIA --
2
by: Zlatko Matić | last post by:
I have several forms hierarchycaly nested in each other (form/subform/subform/subform....). The final form is "continous form", while parent forms are single forms through which navigation was...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
11
by: Martin | last post by:
Hi all! In VB6.0 A combobox had items, which basically were the description and ItemData which could be used to create a link to a record, that is if the recordset had a numeric key. I was...
5
by: TheGanjaMan | last post by:
Hi all, I'm pretty new to programming with vb.net. I'm stuck on a problem: I need to populate a combobox with items and a value for each item. For example if it were for countries: Item -...
1
by: cowznofsky | last post by:
I was databinding to a combobox and supplying both a DisplayMember and a ValueMember, so that each item. Now I've decided against databinding, and will populate it by going through a datatable....
7
by: Tark Siala | last post by:
when i working on VB6 with ComboBox i use ItemData to save Id Number with Visible Name, and use it to get Data from Database. but now i working in VB.NET and se ComboBox, i can Fill Visible Name by...
3
by: bobh | last post by:
Hi All, I've added an 'All' item to my combobox(below) and it does display as the first item If Me.cboLOB.Column(0) = "auto" Then strSQL = "SELECT DISTINCT tblAUTO_MASTER.Section" & _ " FROM...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.