How to put an extended WinForms Control on ToolBox

后端 未结 8 1958
自闭症患者
自闭症患者 2020-12-11 02:53

I plan to add functionalities to TextBox with the following:

   public class TextBoxExt : TextBox  
    {
        protected override void OnKeyPress(KeyPress         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-11 03:45

    I know this is super old question, but maybe still useful for someone else that has same problem like me - as it's still on the top Google :)

    You might interest to use ToolboxItemAttribute (http://msdn.microsoft.com/en-us/library/system.componentmodel.toolboxitemattribute(v=vs.110).aspx).

    I did this at my end to resolve the problem.

    [ToolboxItem(true)]
    public class PanelTitle : LabelControl  {
       // Whatever code to override LabelControl here...
    }
    

    Rebuild the solution and the extended control should be shown in the toolbox.

提交回复
热议问题