Click here to Skip to main content
15,922,007 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created one emulator for one device, so each time the user clicks on the button I am creating one new form, and each form represents new devices.

now I am looking for another option by which inside my main form I can create multiple tabs (instead of multiple forms) which has controls like button, dropdown, text box, grid view. and the user can navigate between tabs, create a new tab dynamically, use controls inside of the tab.

any suggestion ??

What I have tried:

I am thinking about to use 'usercontrol' in my application
Updated 17-Sep-19 21:40pm
[no name] 17-Sep-19 11:21am    
Yes, use user controls (uc) for containing buttons, etc.; then add the uc to the tab. The way to go if you want to add tabs on the fly.

1 solution

Just use the TabControl on your 'main form'. You can easily add tab pages at runtime.

tabControl1.TabPages.Add("New Tab");

Carry on using a form for your 'device'. You can place an entire form inside a tab control ...this code will create a new instance of a form and place it in the last tab of a tab control:

frmDevice dev = new frmDevice();
dev.TopLevel = false;
dev.FormBorderStyle = FormBorderStyle.None;
dev.Parent = tabControl1.TabPages[tabControl1.TabCount - 1];
dev.Dock = DockStyle.Fill;
Share this answer
Varun Nayak89 19-Sep-19 9:47am    
Straight forward and perfect answer !! Thank you very much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900