Click here to Skip to main content
15,886,095 members
Articles / Web Development / HTML

Windows and Web Generic Components

Rate me:
Please Sign up or sign in to vote.
4.08/5 (7 votes)
23 Jul 2008CPOL4 min read 27.3K   742   15  
A method to create Windows and Web components with the same interface
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace App.WinForm
{
	/// <summary>
	/// Summary description for MainFrm.
	/// </summary>
	public class MainFrm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMnu;
		private System.Windows.Forms.MenuItem BaseItm;
        private System.Windows.Forms.MenuItem GeoItm;
        private MenuItem menuItem1;
        private IContainer components;

		public MainFrm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.mainMnu = new System.Windows.Forms.MainMenu(this.components);
            this.BaseItm = new System.Windows.Forms.MenuItem();
            this.GeoItm = new System.Windows.Forms.MenuItem();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.SuspendLayout();
            // 
            // mainMnu
            // 
            this.mainMnu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.BaseItm});
            this.mainMnu.RightToLeft = System.Windows.Forms.RightToLeft.No;
            // 
            // BaseItm
            // 
            this.BaseItm.Index = 0;
            this.BaseItm.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.GeoItm,
            this.menuItem1});
            this.BaseItm.Text = "Relational Forms";
            // 
            // GeoItm
            // 
            this.GeoItm.Index = 0;
            this.GeoItm.Shortcut = System.Windows.Forms.Shortcut.F2;
            this.GeoItm.Text = "Master/Detail";
            this.GeoItm.Click += new System.EventHandler(this.GeoItm_Click);
            // 
            // menuItem1
            // 
            this.menuItem1.Index = 1;
            this.menuItem1.Shortcut = System.Windows.Forms.Shortcut.F3;
            this.menuItem1.Text = "Lookup";
            this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
            // 
            // MainFrm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(795, 544);
            this.IsMdiContainer = true;
            this.Menu = this.mainMnu;
            this.Name = "MainFrm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Prototype";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainFrm());
		}

		private void GeoItm_Click(object sender, System.EventArgs e)
		{
            BaseFrm.MasterDetailForm gf = new BaseFrm.MasterDetailForm();
			gf.MdiParent = this;
			gf.Show();
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            BaseFrm.LookupForm gf = new BaseFrm.LookupForm();
            gf.MdiParent = this;
            gf.Show();
        }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior)
Canada Canada
Software development experience since 1993

Skills
- Programming Languages: C# .NET, Delphi, C++, Java and VB
- Development Methodologies (SDLC): RUP, Scrum and XP
- Database: SQL server, Oracle, Apollo database and MS Access.

Educations & Certificates
- Microsoft® Certified Professional (MCP)
- Sun® Certified Java2 Programmer
- B.S. in computer science

Comments and Discussions