Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A Practical Use of the MVC Pattern

, 8 Jan 2007 CPOL
Another approach to the MVC pattern
using System;
using System.Windows.Forms;
using MvcExample.Controllers;

namespace MvcExample
{
	public class MvcExample : Form
	{
		#region Windows Form Designer generated code
		private System.Windows.Forms.Button butListView;
		private System.Windows.Forms.Button butGraphView;
		private System.Windows.Forms.GroupBox grpDesc;
		private System.ComponentModel.Container components = null;

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

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.butListView = new System.Windows.Forms.Button();
			this.butGraphView = new System.Windows.Forms.Button();
			this.grpDesc = new System.Windows.Forms.GroupBox();
			this.SuspendLayout();
			// 
			// butListView
			// 
			this.butListView.Location = new System.Drawing.Point(8, 208);
			this.butListView.Name = "butListView";
			this.butListView.Size = new System.Drawing.Size(112, 32);
			this.butListView.TabIndex = 0;
			this.butListView.Text = "Show list";
			this.butListView.Click += new System.EventHandler(this.butListView_Click);
			// 
			// butGraphView
			// 
			this.butGraphView.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.butGraphView.Location = new System.Drawing.Point(168, 208);
			this.butGraphView.Name = "butGraphView";
			this.butGraphView.Size = new System.Drawing.Size(112, 32);
			this.butGraphView.TabIndex = 1;
			this.butGraphView.Text = "Show graph";
			this.butGraphView.Click += new System.EventHandler(this.butGraphView_Click);
			// 
			// grpDesc
			// 
			this.grpDesc.Anchor = ((System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
				| System.Windows.Forms.AnchorStyles.Left)
				| System.Windows.Forms.AnchorStyles.Right)));
			this.grpDesc.Location = new System.Drawing.Point(8, 8);
			this.grpDesc.Name = "grpDesc";
			this.grpDesc.Size = new System.Drawing.Size(272, 192);
			this.grpDesc.TabIndex = 2;
			this.grpDesc.TabStop = false;
			this.grpDesc.Text = "Description";
			// 
			// MvcExample
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(288, 245);
			this.Controls.Add(this.grpDesc);
			this.Controls.Add(this.butGraphView);
			this.Controls.Add(this.butListView);
			this.MaximizeBox = false;
			this.Name = "MvcExample";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "A demo of the MVC pattern";
			this.ResumeLayout(false);

		}
		#endregion

		#region constructor
		public MvcExample()
		{
			InitializeComponent();
		}
		#endregion constructor

		#region button eventhandlers
		private void butListView_Click(object sender, EventArgs e)
		{
			RptController controller = new RptController(RptControllerType.List);
		}

		private void butGraphView_Click(object sender, EventArgs e)
		{
			RptController controller = new RptController(RptControllerType.Graph);
		}
		#endregion button eventhandlers
	}
}

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)

Share

About the Author

Zoltan Balazs
Software Developer
Romania Romania
I've did some programming for Macintosh a few years back and working with Microsoft technologies since then.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 8 Jan 2007
Article Copyright 2007 by Zoltan Balazs
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid