Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / October 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kay - 25 Oct 2006 10:35 GMT
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.
Teemu Keiski - 25 Oct 2006 18:17 GMT
Hi,

if the selection list is predefined e.g like TextMode is, just have it as
enum type. It has the selection list applied automatically (quite simple)

Signature

Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

> Hello,
>
[quoted text clipped - 95 lines]
> Thanks,
> Kay.
Teemu Keiski - 25 Oct 2006 18:19 GMT
And now I saw the db stuff. You can create a type converter

http://msdn2.microsoft.com/en-us/library/ayybcxe5.aspx

Signature

Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

> Hello,
>
[quoted text clipped - 95 lines]
> Thanks,
> Kay.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.