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 774059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:04:06+00:00 2026-05-14T19:04:06+00:00

[EDIT] To be clear, I know how to get a list of forms via

  • 0

[EDIT] To be clear, I know how to get a list of forms via reflection. I’m more concerned with the design time property grid.

I have a user control with a public property of the type Form.

I want to be able to select a form at design time from a dropdown.

I want to populate the form dropdown list from a set namespace: UI.Foo.Forms

This would work like if you have a public property of Control. At design time, the property will automatically populate a dropdown with all the controls on the form, for you to select from. I just want to populate it with all the forms in a namespace.

How do I go about doing this? I hope I’m being clear enough so there is no confusion. I’m looking for some code examples if at all possible. I’m trying to avoid having to spend too much time on this when I have other deadlines to meet.

Thanks for your help in advance.

  • 1 1 Answer
  • 0 Views
  • 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-14T19:04:06+00:00Added an answer on May 14, 2026 at 7:04 pm

    You can easily get the classes via Reflection:

    var formNames = this.GetType().Assembly.GetTypes().Where(x => x.Namespace == "UI.Foo.Forms").Select(x => x.Name);
    

    Assuming you’re calling this from code in the same assembly as your forms, you’ll get the names of all the types that are in the “UI.Foo.Forms” namespace. You can then present this in the dropdown and, eventually, instantiate whichever is selected by the user via reflection once more:

    Activator.CreateInstance(this.GetType("UI.Form.Forms.FormClassName"));
    

    [Edit] Adding code for the design time stuff:

    On your control you can create a Form property as such:

    [Browsable(true)]
    [Editor(typeof(TestDesignProperty), typeof(UITypeEditor))]
    [DefaultValue(null)]
    public Type FormType { get; set; }
    

    Which references the Editor type that must be defined. The code is pretty self-explanatory, with a minimal amount of tweaking, you’ll likely be able to get it to produce exactly what you want.

    public class TestDesignProperty : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.DropDown;
        }
    
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
    
            ListBox lb = new ListBox();
            foreach(var type in this.GetType().Assembly.GetTypes())
            {
                lb.Items.Add(type);
            }
    
            if (value != null)
            {
                lb.SelectedItem = value;
            }
    
            edSvc.DropDownControl(lb);
    
            value = (Type)lb.SelectedItem;
    
            return value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: OOPS, sorry I wasn't clear. I have a string that I get from
EDIT: ok let me be a bit more clear i have a html file
i have to make a notepad where i write,edit,clear the text. this notepad need
I have to edit my question just to make it clear. What I need
EDIT: Just to make things clear, this problem was caused by a typo in
EDIT: See my answer below--> I am wanting to have a view that when
Edit (updated question) I have a simple C program: // it is not important
Like in Title I want to get position from List<Vector2> positions = new List<Vector2>{/*here
I have this funny issue. I know this error message is found in a
In my viewmodel, I have a list of items I fetch from the database

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.