Custom Comboboxes to display one value and store another

D

Dan Keeley

Hi

I'm trying to create a custom combo box so i can display a nice text name
but return the actual key value for the database.

So i have this class ( At the bottom of this post )

How do i get the current value?

I have customerlist which is a "comboitem2". The user has selected an item,
but when i ask for customerlist.OptionValue it returns zero...

Have i missed a step somewhere?

Thanks!
Dan

Public Class ComboItem2

Inherits ComboBox

Private m_strName As String

Private m_intAge As Integer

Public Shadows Property Name() As String

Get

Return m_strName

End Get

Set(ByVal Value As String)

m_strName = Value

End Set

End Property

Public Property OptionValue() As Integer

Get

Return m_intAge

End Get

Set(ByVal Value As Integer)

m_intAge = Value

End Set

End Property

Public Overrides Function ToString() As String

Return m_strName & " (" & m_intAge.ToString() & ")"

End Function

End Class
 
D

Dan Keeley

Ahh, ok after a quick break i figured it out.

The trick is to use a standard combo box, with custom combo items.... DOOH!

Thanks anyway !
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top