I need separate instances for each tab.  I have a Tab Control that will add tabs during runtime, and I want each tab to have all the controls as the original

Posted on 2005-04-01
Medium Priority
Last Modified: 2010-04-23
I'm using a tab system that adds a tab every time a user clicks a button, and with that tab the same controls need to come up on each tab.  These controls have to be named the same and access the same databases, so I want it to copy the first instance to a new tab every time a new tab is added.

This program is used to take calls.  A person calls in and the user takes down their information on the first tab.  Then another person calls in, and the user needs to take their information down, so I add another tab with all the same controls on it.

How do I copy all the controls over to the new tab with empty fields, or Open up a bunch of saved controls that access the same database tables.

Can you help?
Question by:RAMCIT
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 10

Expert Comment

ID: 13684227
Make a custom control and use visual inheritance. You can do this by creating a new Windows Control Library ... Compile that and then in your main project add a reference to that dll and you will see your control in the toolbox. If you know this already then I apologize. If not you will also want to take care of the event handling for those controls too. This is one way to do it.

Author Comment

ID: 13684484
How would you make a new Windows Control Library?  How woudl you take care of the event handling?
LVL 10

Accepted Solution

NetworkArchitek earned 2000 total points
ID: 13684599
Well you create a new project and instead of creating a Windows Application you create a Windows Control library. There you have what looks like a "borderless form" but is really just space for you to add your controls. So this is like a way you  extend "built-in" controls. Like you can make a custom login box control, or a control does color mixing (like if you take 3 track bars to represent RGB, and then make a label with a backcolor property, you have made your own control to use in your applications).

So what you do is create your control, put all the code necessary for the immediate control. Since it is your control you can go ahead and program the middle-tier stuff right into the control if you want, like accessing your database.

Ok, and once you do that you need to think about how you want to use that control in your application. Maybe you want a Public Property (which would actually show up in the "Properties" window, like for any other control). Then you need to think about if you want your application to listen for events from that control. Actually it is possible that you could decide that you don't need to listen to any events from that control, if the control has the middle tier stuff coded into it (updating your DB and stuff).

So yes, I guess in your case you may not need events but if you do you want to look up delegates and "raising events" especially from UserControl (that is a custom control class).

This is a way for you to just drag and drop this control on any form you want, or whatever, without "copying" or any of this other business. It works very well. One thing to remember is assign your control a name when you make it, and change the "Class name" in the code view. Otherwise you will have the control being called "UserControl" in your toolbox.

Well, just try it out and I think it will make sense. This seems like the best way to solve your problem. Hope this helps.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question