473,403 Members | 2,293 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,403 software developers and data experts.

Custom Comboboxes to display one value and store another

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
Nov 20 '05 #1
1 1312
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

"Dan Keeley" <ma********@hotmail.com> wrote in message
news:uh******************@newsfep4-glfd.server.ntli.net...
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

Nov 20 '05 #2

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

Similar topics

0
by: johnson_cy | last post by:
I am using Access 2000. My main form has a record source of a table (employeeTbl with key of . It is filtering the record results. My subform and mainform have the link child/link master set...
7
by: Martin Schulze | last post by:
Hello, i tried to compose myself a custom usercontrol which is derieved from System.Windows.Forms.UserControl. It contains 2 comboboxes and one textbox (which are also custom controls, but...
1
by: Nikhil Patel | last post by:
Hi All, I am using a dll function that returns a two diamensional array containing BankNames and RoutingIds. I need to display BankNames and RoutingIds in two different comboboxes. When user...
4
by: David Meier | last post by:
How can data be stored in comboboxes similar to html pulldowns? I know I can access the data of the combobox either by the items text or by its index. However, I would like to have a pulldown...
5
by: Henry | last post by:
Please forgive me if I have missed an obvious answer to this question... I am looking at controls like comboBoxes, ListBoxes, and Trees and trying to understand how to associate what is viewed in...
1
by: Jakob Lithner | last post by:
When I started a new ASP project I was eager to use the login facilities offered in Framework 2.0/VS 2005. I wanted: - A custom principal that could hold my integer UserID from the database -...
0
by: Walter | last post by:
Hi, can someone please help me with my custom control viewstate problem....I haven't slept for hours trying to get this fixed. I am making two custom controls which will be included on a single...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
2
by: Wingot | last post by:
Hey, I have a view to a database that I have created for Client Maintenance. It has a number of fields, but the important ones are Medical Condition, Bill To, and Country. I have a couple of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
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...

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.