473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 26965
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
1610
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
19319
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
1479
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
1521
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
1921
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
3377
by: gourab103111 | last post by:
how get multiple values from combobox using php ,when i retrive value using $_POST
19
4723
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
4208
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
2657
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
1635
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
7086
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
7280
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
7330
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...
1
6991
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...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.