User Controls not showing up in the toolbox

前端 未结 29 2170
暗喜
暗喜 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: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.

提交回复
热议问题