Create and use Custom Controls in Windows Forms

  • Thread starter Thread starter NicePeople
  • Start date Start date
N

NicePeople

Sorry if this has been addresses earlier. I would like to create a custom
button that has some events and some properties set and would like to add
that as an available control from the Tool box.
How is that done?
 
NicePeople said:
Sorry if this has been addresses earlier. I would like to create a custom
button that has some events and some properties set and would like to add
that as an available control from the Tool box.
How is that done?

Create a class library project

public class MySuperButton : System.Windows.Forms.Button
{
you code goes here
}

build the project, right click on the toolbox, select Add Items, browse
to your new dll location, double click on the dll - job done

HTH
 
Create a class library project

public class MySuperButton : System.Windows.Forms.Button
{
you code goes here

}

build the project, right click on the toolbox, select Add Items, browse
to your new dll location, double click on the dll - job done

Or you can drag and drop the dll into the toolbox.
 
NicePeople said:
Sorry if this has been addresses earlier. I would like to create a custom
button that has some events and some properties set and would like to add
that as an available control from the Tool box.
How is that done?

If you are meaning to use the CustomControl within the current solution
only, you can simply create the control and Visual Studio should be able to
pick it up and place it in the ToolBox by itself. You will find it at the
top of your ToolBox under a "<MyNameSpace> Components" section.
 
Back
Top