PC Review


Reply
Thread Tools Rate Thread

How to display a property of a custom control with a dropdown styl

 
 
=?Utf-8?B?S2F5?=
Guest
Posts: n/a
 
      25th Oct 2006
Hello,

I have written my own custom control and I want one of its properties to
display as a dropdown list when clicked, so the user can select from the
list, it would be similar to the asp textbox control which has a ‘TextMode’
property and when clicked on, displays as a dropdown list with 3 values, I
want to have a similar type property with a dropdown style.

So far, I have a property defined which displays the dropdown arrow when
clicked but does not expand, I also do not know how to populate the dropdown.
The dropdown needs to be populated with values read from the DB, the values
can be read into a Dataset/datareader (which I can do), so I need to know how
to bind these to a dropdown and have the dropdown assigned to the property.
So far I have the following:

1. My control

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Text
Imports System.Drawing
Imports UniversalDropdownEditor


Namespace CustomAddressControl

<DefaultProperty("Title"), ToolboxData("<{0}:Address
runat=server></{0}:Address>")> _
Public Class Address
Inherits System.Web.UI.WebControls.WebControl

Private iDataSource As String


<Description("The source/origin of the data."), _
Editor(GetType(EntryModeEditor), _
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property DataSource() As String
Get
Return iDataSource
End Get
Set(ByVal Value As String)
iDataSource = Value
End Set
End Property

…………..

2. My EntryModeEditor Class

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Drawing.Design
Imports System.Windows.Forms


Imports System.Windows.Forms.Design
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Public Class EntryModeEditor
Inherits System.Drawing.Design.UITypeEditor

Public Overloads Overrides Function EditValue(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal provider As
IServiceProvider, ByVal value As Object) As Object

Dim returnValue As Object = value
If Not (provider Is Nothing) Then

‘I DO NOT KNOW WHAT SHOULD GO IN HERE, TO POPULATE THE DROPDOWN AND GET OUT
THE VALUE THAT WAS SELECTED

End If
Return value
End Function


Public Overloads Overrides Function GetEditStyle(ByVal context As _
System.ComponentModel.ITypeDescriptorContext) As _
System.Drawing.Design.UITypeEditorEditStyle
If context Is Nothing Then
Return MyBase.GetEditStyle(context)
Else
Return System.Drawing.Design.UITypeEditorEditStyle.DropDown
End If

End Function

End Class

Any help/suggestions would be gratefully appreciated.

Thanks,
Kay.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2010 Paste Options--Merge Formatting vs. Use Destination Styl Arlene Microsoft Word Document Management 0 25th Feb 2010 02:44 AM
Need macro to find bullet style, add text, and convert normal styl Macro''''er Microsoft Word Document Management 1 1st Nov 2009 07:21 PM
Printing notes section of Personal Contacts in Medium Booklet Styl =?Utf-8?B?TG9va2luZyBpbiBhbGwgdGhlIHdyb25nIHBsYWNl Microsoft Outlook Contacts 1 6th Mar 2006 04:54 PM
in windows xp home i have hotmail and how do i change my font styl =?Utf-8?B?Y2hhbmdpbmcgZm9udHM=?= Windows XP General 1 5th May 2005 01:51 PM
windows and buttons--automatically changes from XP to classic styl =?Utf-8?B?YW5kaQ==?= Windows XP Performance 0 13th Dec 2004 03:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:05 AM.