Search code examples
c#.netcomponentsderived-class

c# derive a class from a component


I have derived a class from a component (DataGridView). How do I place my component in the visual studio components palette.

 class WorkerGrid:DataGridView
{
    public Worker Worker { get; }
    public DateTime DateStart { get; set; }
    public DateTime DateEnd { get; set; }

    public void Load()
    {

    }
}

Solution

  • Depending on Microsoft

    Creating the Project

    The first step is to create the project and to set up the form.

    • Create a Windows-based application project called ToolboxExample
      (File > New > Project > Visual C# > Classic Desktop > Windows Forms Application).
    • Add a new component to the project. Call it DemoComponent.
      • (For more information, see NIB:How to: Add New Project Items.)
    • Build the project.
    • From the Tools menu, click the Options item. Click General under the Windows Forms Designer item and ensure that the AutoToolboxPopulate option is set to True.

    To create an instance of a custom component

    • Open the project's form in the Forms Designer.
    • In the Toolbox, click the new tab called ToolboxExample Components.
    • Once you click the tab, you will see DemoComponent
    • Drag your component onto your form. An instance of the component is created and added to the Component Tray.

    enter image description here