473,486 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Create an User Defined Property for a Combo Box User Contro

How to Create an User Defined Property, which stores value for each index of
the Combo Box User Control.(each value is related to the item stored in the
ComboBox)
--
Peter...
Nov 21 '05 #1
2 1113
Hi,

Databind the combobox to an arraylist filled with a class that holds
the two values.

Dim alCombo As New ArrayList

For i As Integer = 0 To 10

Dim c As New MyComboboxData

With c

..MyReturnValue = "Value " & i.ToString

..show = i.ToString

End With

alCombo.Add(c)

Next

ComboBox1.DataSource = alCombo

ComboBox1.DisplayMember = "show"

ComboBox1.ValueMember = "MyReturnValue"

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

Try

Dim c As MyComboboxData

c = CType(ComboBox1.SelectedItem, MyComboboxData)

Debug.WriteLine(c.MyReturnValue)

Catch ex As Exception

End Try

End Sub

The class

Public Class MyComboboxData

Dim mstrShow As String

Dim mstrValue As String

Public Property show() As String

Get

Return mstrShow

End Get

Set(ByVal Value As String)

mstrShow = Value

End Set

End Property

Public Property MyReturnValue() As String

Get

Return mstrValue

End Get

Set(ByVal Value As String)

mstrValue = Value

End Set

End Property

End Class

Ken

---------------------

"Prabhudhas Peter" <Pr*************@discussions.microsoft.com> wrote in
message news:9C**********************************@microsof t.com...
How to Create an User Defined Property, which stores value for each index of
the Combo Box User Control.(each value is related to the item stored in the
ComboBox)
--
Peter...
Nov 21 '05 #2
As an added shortcut, give your class a "ToString" function that overrides
the base ToString function and return the string you want to display. Then
you don't even have to set the .DisplayMember property.

-Zorpy
Nov 21 '05 #3

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

Similar topics

22
2687
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
4
1247
by: Phil | last post by:
As a new user, I was pleased I was able to build tables and connect them properly (I think), but am having one problem on forms. How does one go about creating a form, where on field on the form...
7
8818
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
0
1228
by: Manish Jain | last post by:
I am trying to implement Partical Caching in a User Control that gets data from DB and populates a combo based on: 1) GroupKey : An int Property that is known for each call (say Source=10, Code=11...
1
1570
by: Howard | last post by:
I have a header control, control.ascx page and a user.aspx page I would like to generate a unique page title for each user. in user.aspx i used this <Controls:Header id="header" runat="server"...
0
1068
by: Eddie | last post by:
In Microsoft Access form, combo box can be binded to the table or query and can be shown as multi column, getting a actual binded column and showing columns. I'm struggling to make a...
37
3242
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
6
12451
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main...
4
6006
by: raghunadhs | last post by:
Hi everybody! I would like to develope an application, in this a should abel to create user defined controls. i should have some properties. when ever i drag and drop that control it should apper...
0
7099
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
6964
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
7175
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
6842
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
5430
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
4864
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
4559
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
3069
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...
1
598
muto222
php
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.