views:

44

answers:

1

This is quite a basic question, that I'm sure many of you will be able to answer and applies not only to TableLayoutPanel, but to all other .NET controls too.

I have created a new class which derives from TableLayoutPanel and I want to use this derivation on the form instead of the .NET version. I am expecting to be able to use drag and drop as one does will all the other controls in the tool box.

However, I am not sure how to do this; I am also guessing that for dervived classes, this drag and drop onto a form can not be done in the designer; and must be done in code only. I am not sure about this and since this is my first .NET forms application, I have no experience to fall back on.

public class CustomTableLayoutPanel : TableLayoutPanel
{
}

The form that hosts this control (not directly) is implemented in a form called MainForm. I suppose I could go into the deigner.cs (MainForm.Designer.cs) file and change the member variable to be of my custom type instead of the .NET type, but I am not sure if this is the established method of performing this kind of function or whether that is a hack. As far as I know, you should not manually change code in and XXXdesigner.cs file since this is automatically generated.

A: 

You must successfully compile your class atleast one time, and then it will appear in the toolbox. Then you can just drag and drop it as you would any other control.

Charles Y.