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

where is ItemData of List/ComboBox ???

hi
in VB6 (Listbox and Combobox) have nice Properties called (Item Data)
when i go to VB.NET i can't Find this Properties :(
please help me , i want Save tow value in one item in ComboBox
1 - Text like (CostumerName) - to show it to user.
2 - Integer (CostumerId) - to working in Database.

any one can help ????

------------------------------------------------
Best Regards From Tark
Jul 21 '05 #1
2 1973
This is what I use in this situation

Me.cmbPMOCat.DataSource = dsCombos.Tables("PMOCat")
Me.cmbPMOCat.DisplayMember = "PMOCatDesc"
Me.cmbPMOCat.ValueMember = "PMOCategory"

The displaymember identifies what shows in the combo box. The valuemember
is the value you want in the db. So you can use the following line to extract
it

sPMOCatV = Me.cmbPMOCat.SelectedValue

Hope this helps
"Tark Siala" wrote:
hi
in VB6 (Listbox and Combobox) have nice Properties called (Item Data)
when i go to VB.NET i can't Find this Properties :(
please help me , i want Save tow value in one item in ComboBox
1 - Text like (CostumerName) - to show it to user.
2 - Integer (CostumerId) - to working in Database.

any one can help ????

------------------------------------------------
Best Regards From Tark

Jul 21 '05 #2
Hello Tark,

A possible way to do what you want as follows:
1. Create a class tha would hold the data items that you want to store for
each item
(for example:
public class itemclass
Public name As String
Public id As Integer

end class
An instanace of this class would contain the name that would appear for
each item and the id for that item. You could add any more data that you
need as properties for that class)

2. Create a constructor for that class that would take the values for a new
instance and set the properties correctly
(for example:
pubic sub new(byval inname as string, byval inid as integer)
name = iname
id = inid
end sub

3. Override the tostring method in that class to return the text you want
to appear for the listbox or combobox items (listbox and combobox call
tostring to show the items.
(for example:
public overrides function tostring() as string
return name
end function

4.
Add items to the list box and combobox using the .items.add method passing
them objects of the the class previously definded
(for example:
ComboBox1.Items.Add(New itemclass("First Item",1))
ComboBox1.Items.Add(New itemclass("Second Item",2))

Now the listbox and combo box should appear correctly and each item has its
id (or dataitem) saved inside it.

5. To retrieve the selecteditem and the dataitem (id) inside it, you could
use the following:
Dim selitem As itemclass = CType(ComboBox1.SelectedItem, itemclass)
message.show(selitem.id)

Hope this walkthrough helps you. Note that now you could save more than one
peice of information as you could define the itemclass class as you like.

Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC

WARNING: Microsoft provides this code "as is" without warranty of any kind,
either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.

"Tark Siala" <ta*******@hotmail.com> wrote in message
news:Oo****************@TK2MSFTNGP12.phx.gbl...
hi
in VB6 (Listbox and Combobox) have nice Properties called (Item Data)
when i go to VB.NET i can't Find this Properties :(
please help me , i want Save tow value in one item in ComboBox
1 - Text like (CostumerName) - to show it to user.
2 - Integer (CostumerId) - to working in Database.

any one can help ????

------------------------------------------------
Best Regards From Tark

Jul 21 '05 #3

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

Similar topics

0
by: Marc | last post by:
Hi all, I have an application that uses a Pmw ComboBox to display a list that is dynamic. The user has the ability to add and delete items from the list at different points in the program. ...
5
by: Andrew | last post by:
I've got two tables in my DB, a Client table and an Event table. There are many events for each client. The form I designed is based off of the Client table and the subform within it is sourced...
2
by: Kathy | last post by:
Scenario: Multiple Divisions. Each Division has multiple Buildings. Each Building has multiple Floors. Each Floor has a Supervisor. Tables: (abbreviated) TblDivision DivisionID Division
2
by: Prabhudhas Peter | last post by:
I need a ComboBox property like "ItemData" in VB.Net as in VB 6.0. The Idea behind this question is, i've created a user control combo box in vb.net with my own set of properties..now i want to...
2
by: Tark Siala | last post by:
hi in VB6 (Listbox and Combobox) have nice Properties called (Item Data) when i go to VB.NET i can't Find this Properties :( please help me , i want Save tow value in one item in ComboBox 1 -...
1
by: charles.kendricks | last post by:
I am trying to set a combo box to list the fields in one of my tables. I am using the code Dim MyControl As Control Set MyControl = Forms!! MyControl.RowSourceType = "Field List"...
4
by: John Brown | last post by:
I am just starting with VB 2005 . VB6 list boxes and combo boxes had ItemData property. I utilized that feature a lot because all I want to create a transaction or entry in a DataBase is the item...
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...
1
by: fniles | last post by:
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...
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:
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
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...

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.