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.
Related
Ok, I'm being really thick here and am having a few minor issues which are turning into major ones in my head:
I have a MainWindow that houses a tab control into which I have several "apps" sitting which all have their own solutions. I have built a neat "loading" control which is housed in the main window but is hidden and is only displayed when one of the displayed pages has a button clicked. However, I don't seem to be able to access the user control from the page.
As an example, I have an admin page which controls users in a database which wotks fine. When I click on the submit button I want to make the user control visible on the MainWindow and when the function is finished to hide the control. I know how to unhide and hide the control just not how to access it. I have attached a representation of the file structure below so you can see the issue I have accessing the MainWindow in the main solution from say the pageAdmin.xaml.
I have been googalizing this for a while and can't seem to find a solution that works. Can anyone point me in the right direction? I am open to any suggestions about how to handle this.
Andy
Just to be sure: what do you mean with "apps"? Do you have one WPF application which hosts different components?
Maybe PRISM (Microsoft Framework) is interesting for you. In PRISM you can dynamically load components from different dlls and host them in one WPF application. It has a build in messaging framwork which works very well and the diffetent dlls don't need any references among themselves.
I'm using a third party Windows Forms library that has some Form theming options such as making the form windows look like Office Forms (class Office2007Form) or like Metro Forms (class MetroForm). The library is made by SyncFusion.
https://www.syncfusion.com/products/windows-forms/office2007form
https://www.syncfusion.com/products/windows-forms/metroform
Unfortunately there isn't a single form class where I can set the theme via a property (something like: SyncFusionForm.Theme = Metro). Instead the classes are separate and as such if I want to support both themes, I have to create duplicate forms for each theme with the same controls and nearly identical code.
Is there some way I can dynamically set something like this up perhaps by simulating multiple inheritance with interfaces? I don't have the source for the form classes so my options are not too flexible. To create a SyncFusion themed form, I currently just create a Windows Form and change the base class from 'Form' to either 'Office2007Form' or 'MetroForm' and then there are a few properties I set for color etc...
Please let me know if anyone has some idea of how I can do this without replicating my controls and code. Thanks in Advance!
My first instinct would be to have everything on a UserControl. You then add the user control to either the Office2007Form or MetroForm instance as required.
I follow the Design pattern principle of 'favour composition over inheritence'
so far I have been using a standard winforms TabControl to host my different modules of my application statically, for example different GridViews. But this way the whole form becomes too big as it contains too many controls.
I would like to separate all the different "pages" each as a UserControl (from what I've heard, that's better than using Forms). Is that ok? And how is that best implemented with Telerik controls?
I thought about using a RadDock control and add my UserControls as tabbedDocuments to it.
DocumentWindow docWindow = new DocumentWindow();
MyUserControls.FirstGrid ctrl = new MyUserControls.FirstGrid();
docWindow.Controls.Add(ctrl);
radDock1.AddDocument(docWindow);
Is that ok to do? Is there a better way?
Forms are very different compared to UserControls. I don't know exactly how you would like to separate the different pages of your application, but a UserControl always requires something to 'host' or display the UserControl in. A Form is a 'standalone window', basically.
Using the RadDock and tabbed documents is a valid way of doing it, but there a plenty of ways to separate different pages in your application, so I can't say which one fits best your requirements.
I have two propositions for you:
If you decide to go with UserControls, you can use RadPageView (or RadDock) and on each RadPageViewPage (or DocumentWindow in RadDock) to add the UserControl in the Controls collection and show it.
You can use the Auto MDI functionality of RadDock and show your forms as MDI windows in it. More information is available here.
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... :)
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