User Controls not showing up in the toolbox

前端 未结 29 2161
暗喜
暗喜 2020-12-13 12:21

I have some UserControls that I created in ProjectA. I have ProjectB that has a windows form that I want to put the controls on. Both of these projects are in a single sol

相关标签:
29条回答
  • 2020-12-13 12:37

    Before trying to add a custom control, make sure that it is compatible with the .Net version of your current project.

    I was trying to add a custom control to toolbox for a project for Windows CE 5.0 and .Net Compact v3.5 on VS2008. I did all those previous suggestions but nothing worked. The control shows up when "show all" is checked but it is grayed , even in "Choose Items" menu is checked.

    I created a new project with .Net v2.0 and it worked perfectly.

    0 讨论(0)
  • 2020-12-13 12:37

    hello its answer Ctrl+Alt+X take this and later u have TOOLBOX :)

    0 讨论(0)
  • 2020-12-13 12:38

    Check this setting:

    Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate

    It should be set to True for this to work.

    0 讨论(0)
  • 2020-12-13 12:38

    For someone who might be working with ToolStripItems (e.g. ToolStripStatusLabel), to actually get your derived control to show up in the dropdown menu (such as the one from StatusStrip), you need to set the class to public then build the solution.

    Also don't forget the designer attribute for your class, something like this:

    using System.Windows.Forms.Design;
    
    [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)]
    public class MyStatusLabel : ToolStripStatusLabel
    {
    }
    

    Took me a while to get it right. Hopefully this can save someone else's time.

    0 讨论(0)
  • 2020-12-13 12:39

    In your UserControl, make sure that New is declared Public. It won't show up if it's just declared Sub New (which defaults to Friend).

    0 讨论(0)
  • 2020-12-13 12:41

    Well, nothing was working for me except this worked...

    1. I create a new project in my solution, and for this project it works so I was going to start using this one
    2. Playing arond, I started tweaking the xml of the csproj file to find out what was wrong with my other project in the same solution and then I reset it as it didn't seem to be working
    3. It is now magically working again in my project

    Not a very good solution but you should try these steps

    1. See if it works in a brand new solution/project.
    2. See if it works in a brand new project in the same solution
    3. If #2 worked, maybe compare .csproj files...somehow mine started working again while I was doing this(this is very frustrating).
    0 讨论(0)
提交回复
热议问题