How to put an extended WinForms Control on ToolBox

后端 未结 8 1953
自闭症患者
自闭症患者 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:46

    Within the same Solution this should work automatically. However, I have found that if the Target Framework aren't matching the Toolbox does not populate. ( I'm assuming really Reference needs to be of version same or lower than target of Reference. ) ( I did get a warning about non-matching Frameworks ) By making these the same Target Framework, Recompile, Restart VS. the control populated correctly. ( I also added the ToolboxItem(true) Attribute)

    0 讨论(0)
  • 2020-12-11 03:47
    1. Build you project with TextBoxExt, make sure it compiles ok.
    2. With the form that you want TextBoxExt on, open the toolbox, right click and select "choose items"
    3. Browse to you .exe or dll that you compiled in 1)
    4. make sure that TextBoxExt has a tick next to it, press ok
    5. TextBoxExt should appear in the toolbox, drag it onto your form

    (There is another way of doing this, opening the designer file and renaming the instances of TextBox to TextBoxExt but manual editing of designer files can be considered hazardous by some)

    0 讨论(0)
提交回复
热议问题