views:

34

answers:

1

i have this class for example:

class labeledtext
{
    private TextBox tb;
    private Label l;
    public labeledtext(Form frm)
    {
        tb = new TextBox();
        l = new Label();
        frm.Controls.Add(tb);
        frm.Controls.Add(l);
    }
    public void SetCaption(string cpt)
    {
        l.Text = cpt;
    }
    public string text()
    {
        return tb.Text;
    }
}

I want to make an object from this class, that can be used in any other project, as a visual object. I want to use it like a text box, drag it from toolbox to my form and put it and so on. how can i do this? I use visual studio 2010, if it is important.

+1  A: 

I think you're looking for a user control.

In the solution explorer, right click, new usercontrol.

You can draw it in design time, and you can drag it wherever you want. (It will appear in the toolbar after you build the solution).

Here is a little guide: LINK

Jonathan