Click here to Skip to main content
15,891,943 members
Articles / Programming Languages / C#

ReadOnlyController: Working with the ReadOnly property on controls

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
18 Dec 2007CPOL1 min read 25.3K   201   14  
The ReadOnlyController is an IExtenderProvider used to easily set the ReadOnly property on controls.
namespace ReadOnlyController.Sample
{
	partial class Form1
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (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.m_ToggleController1Button = new System.Windows.Forms.Button();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.m_ReadOnlyController1 = new DanRigsby.Windows.Forms.ReadOnlyController(this.components);
			this.m_ToggleController2Button = new System.Windows.Forms.Button();
			this.m_ReadOnlyController2 = new DanRigsby.Windows.Forms.ReadOnlyController(this.components);
			this.SuspendLayout();
			// 
			// m_ToggleController1Button
			// 
			this.m_ToggleController1Button.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.m_ToggleController1Button, false);
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.m_ToggleController1Button, false);
			this.m_ToggleController1Button.Location = new System.Drawing.Point(3, 235);
			this.m_ToggleController1Button.Name = "m_ToggleController1Button";
			this.m_ToggleController1Button.Size = new System.Drawing.Size(423, 23);
			this.m_ToggleController1Button.TabIndex = 0;
			this.m_ToggleController1Button.Text = "Toggle ReadOnlyController1";
			this.m_ToggleController1Button.UseVisualStyleBackColor = true;
			this.m_ToggleController1Button.Click += new System.EventHandler(this.m_ToggleController1Button_Click);
			// 
			// textBox1
			// 
			this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.textBox1, true);
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.textBox1, false);
			this.textBox1.Location = new System.Drawing.Point(51, 6);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(375, 20);
			this.textBox1.TabIndex = 1;
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.label1, false);
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.label1, false);
			this.label1.Location = new System.Drawing.Point(10, 9);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(35, 13);
			this.label1.TabIndex = 2;
			this.label1.Text = "label1";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.label2, false);
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.label2, false);
			this.label2.Location = new System.Drawing.Point(10, 36);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(35, 13);
			this.label2.TabIndex = 4;
			this.label2.Text = "label2";
			// 
			// textBox2
			// 
			this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.textBox2, false);
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.textBox2, true);
			this.textBox2.Location = new System.Drawing.Point(51, 33);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(375, 20);
			this.textBox2.TabIndex = 3;
			// 
			// button2
			// 
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.button2, false);
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.button2, true);
			this.button2.Location = new System.Drawing.Point(13, 66);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(172, 23);
			this.button2.TabIndex = 5;
			this.button2.Text = "Sample Button 1";
			this.button2.UseVisualStyleBackColor = true;
			// 
			// button3
			// 
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.button3, true);
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.button3, false);
			this.button3.Location = new System.Drawing.Point(191, 66);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(174, 23);
			this.button3.TabIndex = 6;
			this.button3.Text = "Sample Button 2";
			this.button3.UseVisualStyleBackColor = true;
			// 
			// m_ReadOnlyController1
			// 
			this.m_ReadOnlyController1.ReadOnly = false;
			// 
			// m_ToggleController2Button
			// 
			this.m_ToggleController2Button.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this.m_ToggleController2Button, false);
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this.m_ToggleController2Button, false);
			this.m_ToggleController2Button.Location = new System.Drawing.Point(3, 264);
			this.m_ToggleController2Button.Name = "m_ToggleController2Button";
			this.m_ToggleController2Button.Size = new System.Drawing.Size(423, 23);
			this.m_ToggleController2Button.TabIndex = 7;
			this.m_ToggleController2Button.Text = "Toggle ReadOnlyController2";
			this.m_ToggleController2Button.UseVisualStyleBackColor = true;
			this.m_ToggleController2Button.Click += new System.EventHandler(this.m_ToggleController2Button_Click);
			// 
			// m_ReadOnlyController2
			// 
			this.m_ReadOnlyController2.ReadOnly = false;
			// 
			// Form1
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(431, 290);
			this.Controls.Add(this.m_ToggleController2Button);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.m_ToggleController1Button);
			this.m_ReadOnlyController1.SetEnableReadOnlyControl(this, false);
			this.m_ReadOnlyController2.SetEnableReadOnlyControl(this, false);
			this.MinimumSize = new System.Drawing.Size(388, 196);
			this.Name = "Form1";
			this.Text = "Form1";
			this.ResumeLayout(false);
			this.PerformLayout();

		}

		#endregion

		private System.Windows.Forms.Button m_ToggleController1Button;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private DanRigsby.Windows.Forms.ReadOnlyController m_ReadOnlyController1;
		private DanRigsby.Windows.Forms.ReadOnlyController m_ReadOnlyController2;
		private System.Windows.Forms.Button m_ToggleController2Button;
	}
}

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
Team Leader Interactive Intelligence
United States United States
I am a Team Lead and Senior Software Developer for Interactive Intelligence in Indianapolis, Indiana, USA. I ampretty much exclusively a C# developer but worksquite a bit with javascript, xml, xslt, sql, and other “buzzword” acronyms working in the full gambit of .net development including winforms, webforms, middle teir, database, communication layers, etc.

I also volunteer as the Logisitics Director at the local .Net User’s Group: IndyNDA and stay pretty active in the developer community in Indianapolis.

Comments and Discussions