473,779 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

More than one column in a Combobox?

Can a combobox conatin more than one column? I want to store text in one
column and in the other (hidden) column store integer values which are
associated with the text.

VB.Net 2003

--
|
+-- Thief_
|
Nov 21 '05 #1
6 3565
I believe there is a property called Value that you can store integers
associated with the Text property.

"Thief_" <th****@hotmail .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
Can a combobox conatin more than one column? I want to store text in one
column and in the other (hidden) column store integer values which are
associated with the text.

VB.Net 2003

--
|
+-- Thief_
|

Nov 21 '05 #2
I think you might be thinking of ASP.NET, because I've never seen a value on
a windows forms combobox, only in ASP.NET

"Terry Olsen" <to******@hotma il.com> wrote in message
news:ON******** ******@tk2msftn gp13.phx.gbl...
I believe there is a property called Value that you can store integers
associated with the Text property.

"Thief_" <th****@hotmail .com> wrote in message
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
Can a combobox conatin more than one column? I want to store text in one
column and in the other (hidden) column store integer values which are
associated with the text.

VB.Net 2003

--
|
+-- Thief_
|


Nov 21 '05 #3
Look your MSDN Library for DisplayMember and ValueMember properties. There
are samples that explain what you is needing.

[]s
Cesar

"Thief_" <th****@hotmail .com> escreveu na mensagem
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
Can a combobox conatin more than one column? I want to store text in one
column and in the other (hidden) column store integer values which are
associated with the text.

VB.Net 2003

--
|
+-- Thief_
|

Nov 21 '05 #4
Thief,

In addition to the others. You can use the valuemember and its selected
value.

Be aware that you need for that a datasource. The easiest one is the
datatable however any Ilist implementing array will do that as well with
some more work.

I hope this helps,

Cor
Nov 21 '05 #5
Thanks Ronchese,

I used the following code which does eactly what I need:

Imports System.Windows. Forms
Imports System.Drawing
Imports System.Collecti ons

Public Class USState

Private myShortName As String
Private myLongName As String

Public Sub New(ByVal strlongName As String, ByVal strShortName As
String)
MyBase.New()
Me.myShortName = strShortName
Me.myLongName = strLongName
End Sub

Public ReadOnly Property ShortName() As String
Get
Return myShortName
End Get
End Property

Public ReadOnly Property LongName() As String
Get
Return myLongName
End Get
End Property

Public Overrides Function ToString() As String
Return Me.ShortName & " - " & Me.LongName
End Function
End Class
Public Class ListBoxSample3
Inherits Form
Friend WithEvents ListBox1 As ListBox = New ListBox()
Dim textBox1 As TextBox = New TextBox()

<System.STAThre adAttribute()> _
Public Shared Sub Main()
System.Windows. Forms.Applicati on.Run(New ListBoxSample3( ))
End Sub

Public Sub New()
Me.AutoScaleBas eSize = New Size(5, 13)
Me.ClientSize = New Size(292, 181)
Me.Text = "ListBox Sample3"

ListBox1.Locati on = New Point(24, 16)
ListBox1.Name = "ListBox1"
ListBox1.Size = New Size(232, 130)
textBox1.Locati on = New Point(24, 160)
textBox1.Name = "textBox1"
textBox1.Size = New Size(40, 24)
Me.Controls.Add Range(New Control() {ListBox1, textBox1})

' Populates the list box using DataSource.
' DisplayMember is used to display just the long name of each state.
Dim USStates As New ArrayList()
USStates.Add(Ne w USState("Washin gton", "WA"))
USStates.Add(Ne w USState("West Virginia", "WV"))
USStates.Add(Ne w USState("Wiscon sin", "WI"))
USStates.Add(Ne w USState("Wyomin g", "WY"))

ListBox1.DataSo urce = USStates
ListBox1.Displa yMember = "LongName"
ListBox1.ValueM ember = "ShortName"

End Sub

Private Sub InitializeCompo nent()

End Sub

Private Sub ListBox1_Select edValueChanged( ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ListBox1.Select edValueChanged
If ListBox1.Select edIndex <> -1 Then
textBox1.Text = ListBox1.Select edValue
End If
End Sub
End Class
--
|
+-- Thief_
|

"Ronchese" <ro******@smlin fo.com.br> wrote in message
news:eA******** ******@TK2MSFTN GP14.phx.gbl...
Look your MSDN Library for DisplayMember and ValueMember properties. There
are samples that explain what you is needing.

[]s
Cesar

"Thief_" <th****@hotmail .com> escreveu na mensagem
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
Can a combobox conatin more than one column? I want to store text in one
column and in the other (hidden) column store integer values which are
associated with the text.

VB.Net 2003

--
|
+-- Thief_
|

Nov 21 '05 #6
Very good. :))

Note that you can use DataTables as a datasource, also.

[]s
Cesar

"Thief_" <th****@hotmail .com> escreveu na mensagem
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Thanks Ronchese,

I used the following code which does eactly what I need:

Imports System.Windows. Forms
Imports System.Drawing
Imports System.Collecti ons

Public Class USState

Private myShortName As String
Private myLongName As String

Public Sub New(ByVal strlongName As String, ByVal strShortName As
String)
MyBase.New()
Me.myShortName = strShortName
Me.myLongName = strLongName
End Sub

Public ReadOnly Property ShortName() As String
Get
Return myShortName
End Get
End Property

Public ReadOnly Property LongName() As String
Get
Return myLongName
End Get
End Property

Public Overrides Function ToString() As String
Return Me.ShortName & " - " & Me.LongName
End Function
End Class
Public Class ListBoxSample3
Inherits Form
Friend WithEvents ListBox1 As ListBox = New ListBox()
Dim textBox1 As TextBox = New TextBox()

<System.STAThre adAttribute()> _
Public Shared Sub Main()
System.Windows. Forms.Applicati on.Run(New ListBoxSample3( ))
End Sub

Public Sub New()
Me.AutoScaleBas eSize = New Size(5, 13)
Me.ClientSize = New Size(292, 181)
Me.Text = "ListBox Sample3"

ListBox1.Locati on = New Point(24, 16)
ListBox1.Name = "ListBox1"
ListBox1.Size = New Size(232, 130)
textBox1.Locati on = New Point(24, 160)
textBox1.Name = "textBox1"
textBox1.Size = New Size(40, 24)
Me.Controls.Add Range(New Control() {ListBox1, textBox1})

' Populates the list box using DataSource.
' DisplayMember is used to display just the long name of each state.
Dim USStates As New ArrayList()
USStates.Add(Ne w USState("Washin gton", "WA"))
USStates.Add(Ne w USState("West Virginia", "WV"))
USStates.Add(Ne w USState("Wiscon sin", "WI"))
USStates.Add(Ne w USState("Wyomin g", "WY"))

ListBox1.DataSo urce = USStates
ListBox1.Displa yMember = "LongName"
ListBox1.ValueM ember = "ShortName"

End Sub

Private Sub InitializeCompo nent()

End Sub

Private Sub ListBox1_Select edValueChanged( ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ListBox1.Select edValueChanged
If ListBox1.Select edIndex <> -1 Then
textBox1.Text = ListBox1.Select edValue
End If
End Sub
End Class
--
|
+-- Thief_
|

"Ronchese" <ro******@smlin fo.com.br> wrote in message
news:eA******** ******@TK2MSFTN GP14.phx.gbl...
Look your MSDN Library for DisplayMember and ValueMember properties. There
are samples that explain what you is needing.

[]s
Cesar

"Thief_" <th****@hotmail .com> escreveu na mensagem
news:eK******** ******@TK2MSFTN GP14.phx.gbl...
Can a combobox conatin more than one column? I want to store text in one
column and in the other (hidden) column store integer values which are
associated with the text.

VB.Net 2003

--
|
+-- Thief_
|


Nov 21 '05 #7

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

Similar topics

27
3274
by: DraguVaso | last post by:
Hi, The Multi column comboBox is a well spoken control, that a lot of people desire, and a lot of people buildtheir own. I tested a lot of them, but none really was what i wanted to have. But does anybody knows where I can find the best Multi column combobox? One that supports a lot of columns, possiblities to get the values in each column for the selected item, adding a DataSource etc... It should be free, and if possible with the...
2
4068
by: Arnie | last post by:
I have searched this NG for datasheet column width posts and have read many of them. None of them seem to address what I would like to do. I'm beginning to think what I want can't be done. Here is what I would like: I have a datasheet form with five columns. The third column is a combobox with two visible columns. The final displayed value and bound column is column 1. The width of the third datasheet column is wide enough to see...
3
3030
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can download a fully working C# sample with the Northwind.mdb here: www.insightgis.com.au/web/stuff/DataGridCombo.zip
2
4543
by: jaYPee | last post by:
i have search a lot of newsgroup and some website to find a sample for multi column combobox in datagrid but no luck. there are so many sample i found but it is not located in datagrid. i would be very glad if you can direct me to a website that has this sample thanks in advance.
17
7438
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5 columns in it but i need to add a sixth column which will be my checkbox column - any help or pointers with this would be great
2
1315
by: Mike TI | last post by:
March 26, 2006 Hi All I am new to VB.Net, using VB.Net 2005 Is there a way to have more than one column in a combo box. Thanks
4
8642
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone tell me if this is even possible, and if so, how to do it? If this is completely impossible, how would you suggest going about sorting a ComboBox wherein the text displayed in the column is the client's name, and the underlying value is an ID? ...
1
2385
by: Coll | last post by:
I'm trying to create a combo box using the wizard. It's based on a query with 5 fields - enum, ename, startdate, enddate, and recordnumber. In my query enum is not visible, and that field has criteria that comes from a text field on a form. The query works fine. When creating the combo box (using the wizard), I select the fields I want to add, then click Next and receive the error message. Any ideas why this is happening? Some of the...
0
1608
by: marisenthil | last post by:
i am created windows application. i have a gridview in form1 with combobox column. using binding source binded data from the database to gridview except combobox column. i used separate binding source to bind combobox column. at the form load time i set index for combobox column for each record. if i set form1 as start page ,combobox indexes are seted i also created mdi form with menu control. if i open form1 through mdi form its...
0
9633
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10074
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8959
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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 we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.