Results 1 to 5 of 5

Thread: Master WindowS Form for Windows App

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    Master WindowS Form for Windows App

    Find a lot talking about MasterPage for ASP.NET, but Couldn't find a sample master winform for business app.

    I am looking for something like this:

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace MyNS
    {
        public partial class frmCommon : Form
        {
            private  Form _CallingForm;
            private string _CallingRole;
            private string _UserRole;
    
    
            public Form CallingForm
            {
                get { return _CallingForm;}
                set { _CallingForm =value;}
    
            }
            public string CallingRole
            { 
                get {return _CallingRole;}
                set {_CallingRole =value ;}
                
            }
            public string UserRole
            {
                get { return _UserRole; }
                set { _UserRole = value; }
            }
    
            public frmCommon()
            {
                InitializeComponent();
            }
    
            public frmCommon(Form callingform,  string callingrole, string userrole)
            {
                _CallingRole = callingrole;
                _CallingForm = callingform;
                _UserRole = userrole;
    
                InitializeComponent();
            }
    
            public virtual void FormFormat{}
            public virtual Bool FormValid { }
            public virtual Bool FormClean { }
            public virtual Bool FormSave { }
            public virtual bool FormLoad { }
     
        }
    }
    looking for professional code sample in c#, thanks

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Master WindowS Form for Windows App

    Are you talking about MDI Apps?
    because there is no such thing as "Master Form"
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    Re: Master WindowS Form for Windows App

    no. I am talking about abstract Master win form which will be be inherited by all other windows forms. This will force coding in all forms with same override methods and variables(standardize coding logic).

  4. #4

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Master WindowS Form for Windows App

    There is no specific feature in Windows Forms to do this. If you want all your forms to inherit specific properties you should define your own class that inherits Form and is declared abstract. You then derive all the forms in your app from that class instead of from Form. Having said that, I'm not 100% sure that the IDE won't override some of your properties when the form is added to the project because it likes to set some default values. Only one way to find out though.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width