Docking c# winforms of multiple instances of the same appliction - c#

I have a c# .net 2.0 winforms application which consists basically of one form A.
I am building another form B with a tabcontrol on it.
From the form B, I would like to be able to create one or more instances of this application.
Each form A I would like to be placed on tabpages on form B's tabcontrol.
Each instance is a different process that is running on a separated folder.
How could I achieve this?
Another way to put this is, how I could dock a form from another running instance into the current application instance's form.

Look at this codeproject article. It is what you are searching for.

I think the best way to do this would be to have to versions of your app. One is the executable and the other is a component that you could add dynamically. I have an app that I do this with tool controls. Each tool represents a separate set of functionality that can be added to a workspace (tab) depending on the user's need for it. For example, I have a tool for logging particular items that's called "logger" and a user can create a new instance of it which essentially adds it as a new tab in the main window. Just a thought. I think docking two running instances of the same application would have to be handled by Windows through the app docking interface.

If you don't control the source code for both of these applications then I don't think you can accomplish your objective.
If you DO control the source code, then I would recommend that you isolate the Form A functionality in a usercontrol in a separate library and reference this from the form in AppA and from the tab control in App B

Related

winform application master form

I was working on an application using asp.net and C# and It made it very easy to develop using the notion of Master Pages.
now I am trying to develop a windows form application and I really need to have a master page here also.
is there anything such as a master form ?
thank you
to simulate master-pages in winform you could cretae a base form, create either a class that inherits from System.windows.Forms or simply add a new form to your project, add the common controls and then create any other form adding an "Inherited Form" select the base form created and that should work
http://www.akadia.com/services/dotnet_inherited_forms.html
There really isn't anything baked-in within Winform that works like ASP.NET master pages.
The closest you can get is having template forms with holes to be filled with user controls. You can connect your controls to "services" instances of the main form represented as interfaces types so that you can react on actions taken on controls owned by the template.
Be warned though, this isn't trivial and you're likely to face some unexpected limitations. Winform might not be the best platform for your new application because of that.

Reducing Complexities in Single form Application

I've created a win form application which consist of a single form. We have 8 tabs to access the modules of application.
The problem is we are a team of 4 who works on this project. But since it is a single form application, only one person can use the file at a time. Is there anyother way to build application with more than one file?
Please provide some solution.
Firstly, you should probably have a separate UserControl per tab. That will give you 8 files (at least) since you have 8 tabs.
Secondly, you should be using a Model-View-Controller style architecture for Windows Forms applications. That will give you at least one controller, but likely you will have one controller per UserControl (i.e. per tab). You might even have an overall controller that manages the per-tab controllers.
You might only have one data model for the entire app, or you might have one data model per UserControl (tab).
If you did all that, you'd have a few more source files.
However, it's actually difficult to say without knowing anything about your app.
Try using user controls to make each tab modular.
Figure out what are the parameters that each tab accepts and that it exposes and then create user controls that have that behavior.
Here are couple resources to get you started
http://msdn.microsoft.com/en-us/library/aa302342.aspx
User Control vs. Windows Form
User Controls in Windows Forms - Anything similar to ASP.NET User Controls?
Even if this is a giant ball of wax, your source control tools are shoddy and breaking it up into separate classes is hard to do, you can still take advantage of a Form class being a partial class. Which means that you can spread the code over any number of source code files, not just the two files that the designer creates. So a logical organization is to move code that belongs to a particular tab in its own partial class with the same form class name and its own source code file. Some cut+paste required however when you add event handlers with the designer.
Have you considered using MDI?
MSDN Working with MDI...
Examples are in VB.Net but I'm sure it will be easy to use C# if you really want to - I'm not sure why, but... :)

Multiple forms or one form and add controls

I am creating a windows mobile application that has several different screens. At the bottom of each screen is a menu bar which the user can click on to navigate each screen.
My question is should I use a new form for each screen and clone the menu or use one form and have all the other screens as a control and add them to the main form?
Cheers
I'd vote for controls.
Both mechanisms can achieve the flow you want, and from a fundamental perspective neither is going to really be worse (as in load times, memory consumed, or what have you) so it's largely a personal style decision. Me, I use a UI framework that lends itself heavily to UserControls, so that's what I use.
Generally speaking, when I create an app I have a single parent/host form that has Workspaces where I put my Views. Thos Views are UserControls. Whether I use a tabbed workspace or a desk workspace, they still end up as Controls. The only reason I use more than one full-up Form is if I have a dialog (warnings, inputs, etc) where I will be doing a ShowDialog call.
Per this link, there is no MDI functionality in Windows Mobile.
In our application, we use different forms for each screen.
There are two ways to open up new windows:
formName.ShowDialog(): the new screen will be opened as a child of the other screen. In this case, you won't be able to access your parent form until the child is closed.
formName.Show(): the new screen will NOT be opened as a child of the other screen. Hence, you can access your parent even if the child is not closed.
You can use TabControl in single form with each tab having it's own controls. No need to add controls dynamically. And one single form. The way to achieve this is discussed in more detail in this answer.
Creating Wizards for Windows Forms in C#

Creating "subforms" in WPF?

I'm pretty new to WPF and C#. I am looking to create multiple windows with in one primary window, like creating forms and subforms in Microsoft Access. I would like to work with One main .xaml and have two seprate .xaml's that the user will open with a button selection. I do not want to have multiple windows pop up (if possible). Instead I would like the main .xaml to display the selected .xaml with-in itself.
Create a User Control and switch the visualization, more examples: http://windowsclient.net/learn/video.aspx?v=76360
You can user user controlls for this. This is a good walkthrough http://www.codeproject.com/KB/WPF/UserControl.aspx
As the other individuals have said, you'll want to create a User Control. It's fairly good practice to create User Controls where possible if you'll be re-using the code.

How would i make another application's child window into a tab? (C#)

For instance, I have an application that has a main window and then child windows inside of it.
http://screenshots.rd.to/sn/e3hek/sapienfullwindow.png
http://screenshots.rd.to/sn/e3hek/appscreen8.png
What i need is to grab each individual child window of that application, and display them as tabs in my application, or on a panel's handle.
I already have code to kidnap the application and put it into mine, and it works great.
MDI support is already present in the C#. So the first screenshot is using the MDI option.
The second screenshot is using tabbed windows. Now you have two options:
Use this opensource library DockPanelSuite which will let you have tabs in your application. something similar to visual studio interface. You can create forms and then tab it based on your needs. You can even dock them anywhere in the parent form by drag and drop. Just like in visual studio.
The second option is to create a form with tab control covering the whole windows. There you create tabs using the resource editor and hide/show based on the forms you want to display to the end user.
In my opinion, use the first option which gives you lot more customization. Also if you use the dockpanel, you can switch between the views shown in your first screenshot and second one. So user has better control as to how he wants to view. Dockpanel is free to use even in commerical apps and comes with source code. So you can either use the dll or directly incorporate the code in your application.

Categories