473,505 Members | 14,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ComboBox ValueMember = Null??? Can't set ValueMember!

Hello all,

I can't seem to set the value member properly in code... I'm using a
ComboBox in DropDownList mode:

Private Class ApplicationsComboBoxItem
Private _Name As String
Private _Application As ApplicationWorker

Public Sub New(ByVal Name As String, ByVal Application As
ApplicationWorker)
_Name = Name
_Application = Application
End Sub

Public ReadOnly Property Name() As String
Get
Return _Name
End Get
End Property

Public ReadOnly Property Value() As ApplicationWorker
Get
Return _Application
End Get
End Property
End Class

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

ApplicationsComboBox.DisplayMember = "Name"
ApplicationsComboBox.ValueMember = "Application" 'Doesn't set
properly for some reason???
ApplicationsComboBox.SelectedIndex = 0
End Sub

Any ideas?!?!?!?!?!

Thanks!
Jun 13 '07 #1
5 2706
Here's is my code:

Private Class ApplicationsComboBoxItem
Private _Name As String
Private _Application As ApplicationWorker

Public Sub New(ByVal Name As String, ByVal Application As
ApplicationWorker)
_Name = Name
_Application = Application
End Sub

Public ReadOnly Property Name() As String
Get
Return _Name
End Get
End Property

Public ReadOnly Property Application() As ApplicationWorker
Get
Return _Application
End Get
End Property
End Class

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

For Each App As ApplicationWorker In Engine.Applications
With ApplicationsListView.Items.Add(App.Name)
.Tag = App
.SubItems.Add(App.State.ToString)
AddHandler App.StateChanged, AddressOf
Application_StateChanged
End With

ApplicationsComboBox.Items.Add(New ApplicationsComboBoxItem
(App.Name, App))
Next

ApplicationsComboBox.DisplayMember = "Name"
ApplicationsComboBox.ValueMember = "Application" 'Doesn't set
properly for some reason???
ApplicationsComboBox.SelectedIndex = 0
End Sub

There was a typo in the last message - any ideas why this doesn't work?
Jun 13 '07 #2
On Jun 12, 10:05 pm, Spam Catcher <spamhoney...@rogers.comwrote:
Here's is my code:

Private Class ApplicationsComboBoxItem
Private _Name As String
Private _Application As ApplicationWorker

Public Sub New(ByVal Name As String, ByVal Application As
ApplicationWorker)
_Name = Name
_Application = Application
End Sub

Public ReadOnly Property Name() As String
Get
Return _Name
End Get
End Property

Public ReadOnly Property Application() As ApplicationWorker
Get
Return _Application
End Get
End Property
End Class

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

For Each App As ApplicationWorker In Engine.Applications
With ApplicationsListView.Items.Add(App.Name)
.Tag = App
.SubItems.Add(App.State.ToString)
AddHandler App.StateChanged, AddressOf
Application_StateChanged
End With

ApplicationsComboBox.Items.Add(New ApplicationsComboBoxItem
(App.Name, App))
Next

ApplicationsComboBox.DisplayMember = "Name"
ApplicationsComboBox.ValueMember = "Application" 'Doesn't set
properly for some reason???
ApplicationsComboBox.SelectedIndex = 0
End Sub

There was a typo in the last message - any ideas why this doesn't work?
Shouldn't that be ApplicationsComboBox.ValueMember = "Value" ? There
is no property named "Application" in your ApplicationComboBoxItem
class.

Chris

Jun 13 '07 #3
Spam Catcher,

As far as I know, DisplayMember and ValueMember only work when the
combobox/listbox is assigned a DataSource.

In your case, you might want to add a ToString method to your
ApplicationsComboBoxItem class that returns the Name property. This will be
displayed in the combobox.

Then, when an item in the combobox is selected, the SelectedItem property
will return a ApplicationsComboBoxItem item. You can then get itsApplication
property.

Kerry Moorman
"Spam Catcher" wrote:
Here's is my code:

Private Class ApplicationsComboBoxItem
Private _Name As String
Private _Application As ApplicationWorker

Public Sub New(ByVal Name As String, ByVal Application As
ApplicationWorker)
_Name = Name
_Application = Application
End Sub

Public ReadOnly Property Name() As String
Get
Return _Name
End Get
End Property

Public ReadOnly Property Application() As ApplicationWorker
Get
Return _Application
End Get
End Property
End Class

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

For Each App As ApplicationWorker In Engine.Applications
With ApplicationsListView.Items.Add(App.Name)
.Tag = App
.SubItems.Add(App.State.ToString)
AddHandler App.StateChanged, AddressOf
Application_StateChanged
End With

ApplicationsComboBox.Items.Add(New ApplicationsComboBoxItem
(App.Name, App))
Next

ApplicationsComboBox.DisplayMember = "Name"
ApplicationsComboBox.ValueMember = "Application" 'Doesn't set
properly for some reason???
ApplicationsComboBox.SelectedIndex = 0
End Sub

There was a typo in the last message - any ideas why this doesn't work?
Jun 13 '07 #4
Chris Dunaway <du******@gmail.comwrote in news:1181740240.590026.306000
@x35g2000prf.googlegroups.com:
Shouldn't that be ApplicationsComboBox.ValueMember = "Value" ? There
is no property named "Application" in your ApplicationComboBoxItem
class.
It was a typo the original post - I posted the correct code - and it still
didn't work!
Jun 13 '07 #5
=?Utf-8?B?S2VycnkgTW9vcm1hbg==?= <Ke**********@discussions.microsoft.com>
wrote in news:B6**********************************@microsof t.com:
As far as I know, DisplayMember and ValueMember only work when the
combobox/listbox is assigned a DataSource.
What's string is that the NAME field works OK, but the value field does
not. It's so inconsistent...
Jun 13 '07 #6

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

Similar topics

3
4236
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
0
1481
by: CalPARK InterNetStation | last post by:
Could anyone explain why the difference of behavior betweein Case1 and Case2 occurs? Microsoft Visual C#.NET 55607-652-0000007-18218 Windows Forms Application 1. put a TabControl on a Form...
3
3016
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...
2
4316
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
1531
by: Dica | last post by:
i've got a dataSet that looks like the following: <tblTasks> <id>0</id> <summary>-- Select A Task--</summary> </tblTasks>
2
1557
by: pmcguire | last post by:
OK. So I've been to http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp and learned a lot about what I might do with a datagrid. But I'm STILL not able to do what I want to do. I want to be able...
30
4517
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
2
2468
by: einsson | last post by:
I face a problem, please help. Error I hit when there are three combobox. Please refer the code with italic characters. this.comboBox1.DataSource = this.dataSet11.Tables;...
1
4210
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...
0
7216
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
7367
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
7018
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
7471
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
5613
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,...
1
5028
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
3187
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
1528
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 ...
0
407
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...

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.