Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1035449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:32:38+00:00 2026-05-16T14:32:38+00:00

I have a UserControl that exposes a System.Type property. I want to make it

  • 0

I have a UserControl that exposes a System.Type property. I want to make it settable at design time, like the BindingSource’s DataSource property. Ultimately, I would like the designer code to generate this:

this.EntityType = typeof(Company.Product.Class);

Where the class selection would come from the project’s registered Data Sources.

Right now I’m exposing a BindingSource directly for the effect, but I’d love to know how can I replicate its behavior for my control.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:32:39+00:00Added an answer on May 16, 2026 at 2:32 pm

    This post helped me with this same type of problem.

    Visual Studio Design Time Property – Form List Drop Down

    This is my implementation, it creates a drop down of types that are accessible from the current project, and filters them by their base class.

    You have to add a reference to EnvDTE

        Public Class EditChildFormDesignerTypeEditor
        Inherits UITypeEditor
    
        Public Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle
            Return UITypeEditorEditStyle.DropDown
        End Function
    
        Public Overrides Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value As Object) As Object
            Dim edSvc = DirectCast(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)
    
    
            Dim dte As EnvDTE.DTE = context.GetService(GetType(EnvDTE.DTE))
            If dte Is Nothing Then Throw New InvalidOperationException("DTE not found.")
    
            Dim lb As New ListBox()
    
            For Each proj As Project In dte.Solution.Projects
                For Each ce As CodeElement In proj.CodeModel.CodeElements
                    If ce.Kind = vsCMElement.vsCMElementClass Then
                        Dim ccl As CodeClass = ce
                        If ccl.IsDerivedFrom(GetType(frmEditChildItem).FullName) Then
                            Dim Tp As Type = Type.GetType(ccl.FullName)
                            If Tp IsNot Nothing Then
                                lb.Items.Add(Tp)
                            End If
                        End If
                    End If
                Next
            Next
    
            If value IsNot Nothing Then
                lb.SelectedItem = value
            End If
    
            edSvc.DropDownControl(lb)
    
            value = DirectCast(lb.SelectedItem, Type)
    
            Return value
        End Function
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that exposes a property of type ImageSource. I want
I have a UserControl that takes a class object as property DataSource. On DataBind,
I have created a user control (CheckedDirTree) that exposes a CheckedFolder property which in
I have an UserControl that contains a Button : <UserControl> <Button> </UserControl> I want
I have a UserControl that I want to add at runtime to my current
I have a UserControl that incorporates a textbox. I want to set the keyboardfocus
I have a Silverlight UserControl which uses the ContentPropertyAttribute to exposes the Children property
I've created a UserControl called CatalogBrowser which has a property ListedFamilies that exposes the
I have a UserControl that has a BaseClass object as a public member. Right
I have a usercontrol that hides a div when a button is clicked. <asp:LinkButton

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.