Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put an extended WinForms Control on ToolBox

Tags:

c#

winforms

I plan to add functionalities to TextBox with the following:

   public class TextBoxExt : TextBox  
    {
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);
        }

    }

The question is how can we use this TextBoxExt? Is there anyway to get this class onto the ToolBox so that we can just drag and drop it onto the form? If not, what is the best way to use the TextBoxExt?

like image 750
david.healed Avatar asked Jul 12 '09 16:07

david.healed


1 Answers

  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)

like image 194
Calanus Avatar answered Sep 20 '22 15:09

Calanus