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

Two Values in an item of a combobox

Hi,

i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store
id's or phonenumbers or something else. i don't want to
have a database!

thanks
yavuz
Nov 20 '05 #1
7 26955
use displayMember and valueMember properties for the bound data

--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Yavuz Bogazci" <ya***@bogazci.com> wrote in message
news:18****************************@phx.gbl...
Hi,

i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store
id's or phonenumbers or something else. i don't want to
have a database!

thanks
yavuz

Nov 20 '05 #2
I have no bound data. i do not use a db !

-----Original Message-----
use displayMember and valueMember properties for the bound data
--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Yavuz Bogazci" <ya***@bogazci.com> wrote in message
news:18****************************@phx.gbl...
Hi,

i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store id's or phonenumbers or something else. i don't want to
have a database!

thanks
yavuz

.

Nov 20 '05 #3
Private Structure vpair

dim text As String

dim value As Int32

End Structure

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim ivp As New vpair

ivp.text = "Hello"

ivp.value = 60

ComboBox1.Items.Add(ivp)

MessageBox.Show(ComboBox1.Items(2).text)

MessageBox.Show(ComboBox1.Items(2).value)

End Sub
--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Yavuz Bogazci" <ya***@bogazci.com> wrote in message
news:18****************************@phx.gbl...
Hi,

i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store
id's or phonenumbers or something else. i don't want to
have a database!

thanks
yavuz

Nov 20 '05 #4
actually it needs 2 be a class

Private Class vpair

Public text As String

Public value As Int32

Public Overrides Function toString() As String

Return text

End Function

End Class
--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"One Handed Man" <te***************************@BTOpenworld.com> wrote in
message news:OM**************@tk2msftngp13.phx.gbl...
Private Structure vpair

dim text As String

dim value As Int32

End Structure

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim ivp As New vpair

ivp.text = "Hello"

ivp.value = 60

ComboBox1.Items.Add(ivp)

MessageBox.Show(ComboBox1.Items(2).text)

MessageBox.Show(ComboBox1.Items(2).value)

End Sub
--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Yavuz Bogazci" <ya***@bogazci.com> wrote in message
news:18****************************@phx.gbl...
Hi,

i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store
id's or phonenumbers or something else. i don't want to
have a database!

thanks
yavuz


Nov 20 '05 #5
"Yavuz Bogazci" <ya***@bogazci.com> schrieb
i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store
id's or phonenumbers or something else. i don't want to
have a database!


You can add any type of object to a combobox. The ToString function of the
object returns what has to be displayed in the combobox.

Taken from a previous post:
class MyComboitem
public readonly ID as integer
public readonly Text as string
public sub new(byval ID as integer,byval Text as string)
me.id=id
me.text=text
end sub
public overrides Function ToString as string
return Text
end function
end class

'code adding items:
dim item as mycomboitem
item = new mycomboitem(theid, thetext)
combobox1.items.add(item)

'to retrieve the id from an item:
dim item as mycomboitem
item = directcast(combobox1.items(0), mycomboitem)
msgbox(item.text)

--
Armin

Nov 20 '05 #6
great! thank you!

yavuz

-----Original Message-----
actually it needs 2 be a class

Private Class vpair

Public text As String

Public value As Int32

Public Overrides Function toString() As String

Return text

End Function

End Class
--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"One Handed Man" <terry_burnsREMOVE%FOR%NO% SP**@BTOpenworld.com> wrote inmessage news:OM**************@tk2msftngp13.phx.gbl...
Private Structure vpair

dim text As String

dim value As Int32

End Structure

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim ivp As New vpair

ivp.text = "Hello"

ivp.value = 60

ComboBox1.Items.Add(ivp)

MessageBox.Show(ComboBox1.Items(2).text)

MessageBox.Show(ComboBox1.Items(2).value)

End Sub
--
Regards - One Handed Man

Author : Fish .NET & Keep .NET
=========================================
This posting is provided "AS IS" with no warranties,
and confers no rights.
"Yavuz Bogazci" <ya***@bogazci.com> wrote in message
news:18****************************@phx.gbl...
> Hi,
>
> i have a question: how can i add items to my comboboxes > with more informations. For Example i want to show the > names of my customers an behind the names i want to store > id's or phonenumbers or something else. i don't want to > have a database!
>
> thanks
> yavuz


.

Nov 20 '05 #7
Hello,

"Yavuz Bogazci" <ya***@bogazci.com> schrieb:
i have a question: how can i add items to my comboboxes
with more informations. For Example i want to show the
names of my customers an behind the names i want to store
id's or phonenumbers or something else. i don't want to
have a database!


http://groups.google.de/groups?selm=...TNGP09.phx.gbl

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #8

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

Similar topics

1
by: dburns | last post by:
I have an unbound ListBox and an unbound ComboBox on the same form. I have them both set up to display the values from the same field in the same table. The ListBox displays the correct values; the...
2
by: Hanumanth Reddy | last post by:
Any one could help how to bind two table field values into combobox display member property. I mean i have two fields in a table. One is states description and another is states codes.I want to...
1
by: Kenneth Hutson | last post by:
Hi group, Sorry, I had erroneously posted this question earlier in the wrong newsgroup. I have an Access database with two tables. The tables are OFFICES and STATES. Table STATES has two...
1
by: manojsingh | last post by:
hi, I am generating combo.All combo has diffrent names. combo contain three values - L,EL and LWP Agian there is three text box that shows the rest CL,EL,LWP values which is not editable....
1
by: neehakale | last post by:
Pls tel me how to pass values to combobox in c# winforms.i simply want to pass the values not form database and all i want to pass values to combobox form file and after clicking that value it...
1
by: gourab103111 | last post by:
how get multiple values from combobox using php ,when i retrive value using $_POST
19
by: billa856 | last post by:
Hi, I have to use the table(PRODUCTION) already generated in MS Access in which all fields are of TEXT type.fields like (orderdate,palletno,customercode,itemno,pono,carto n,pcs,totalquantity)Now i...
1
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound...
4
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the...
4
by: needanswer | last post by:
Is possible to have different values of combobox on the multi same form? Actually I want to make a multi same form, but with one combobox to set the authority. When different persons to use this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.