Peter
Peter

Reputation: 213

Adding existing User Controls as TabPages in a TabControl

I have several Visual Studio 2003 c# projects, each of them containing a "User Control" item where I read some input data from text boxes, perform some calculations when a button is clicked and display the results in text boxes. The outputs of these projects are dll files.

The thing is I would like to create a separate project with a TabControl item and add the "User Control" items from my existing projects as TabPages. It is important to keep intact the existing event handlers of my "User Control" items. The output of the resulting project should also be a dll file. How do I do it? Maybe somebody knows a different way to obtain the same result?

Thank you very much! Peter

Upvotes: 1

Views: 2427

Answers (1)

competent_tech
competent_tech

Reputation: 44921

If this is a winforms application, then you need to take a couple of steps:

1) Add references to each of the UserControl project DLLs to your application.

2) Add the controls to your tab pages. There are two options:

a) Add the control through code at run time.

b) Add the control to the form at design time (I prefer this method, but both are correct). To do this: open the form that you want to place the controls on, open the toolbox, if it isn't already, then drag each of the project DLLs onto the toolbox. This should create items in the toolbox to chose from that match your usercontrols. Create a tab for each user control, then drag the appropriate item from the toolbar to the tab; this should create the user control in the tab.

Upvotes: 1

Related Questions