Click here to Skip to main content
15,892,537 members
Articles / Desktop Programming / Windows Forms

Form Changed Control

Rate me:
Please Sign up or sign in to vote.
4.79/5 (13 votes)
26 May 2008CPOL2 min read 91.3K   1.9K   80  
A component that allows you to monitor all the controls on the form and list any that have changed (for dirty checking)
namespace Form_Change_Control_Test_CSharp
{
    partial class Form_Changetest
    {
        /// <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.formChangedComponent1 = new Form_Change_Control_Test_CSharp.FormChangedComponent(this.components);
            this.textBox_Employeename = new System.Windows.Forms.TextBox();
            this.checkBox1 = new System.Windows.Forms.CheckBox();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.Button_WhatChanged = new System.Windows.Forms.Button();
            this.Button_Reset = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // textBox_Employeename
            // 
            this.formChangedComponent1.SetChangeEventToMonitor(this.textBox_Employeename, "TextChanged");
            this.textBox_Employeename.Location = new System.Drawing.Point(118, 13);
            this.formChangedComponent1.SetMonitorForChanges(this.textBox_Employeename, true);
            this.textBox_Employeename.Name = "textBox_Employeename";
            this.textBox_Employeename.Size = new System.Drawing.Size(162, 20);
            this.textBox_Employeename.TabIndex = 0;
            this.formChangedComponent1.SetValueNameToMonitor(this.textBox_Employeename, "Text");
            // 
            // checkBox1
            // 
            this.checkBox1.AutoSize = true;
            this.formChangedComponent1.SetChangeEventToMonitor(this.checkBox1, "CheckedChanged");
            this.checkBox1.Location = new System.Drawing.Point(16, 39);
            this.formChangedComponent1.SetMonitorForChanges(this.checkBox1, true);
            this.checkBox1.Name = "checkBox1";
            this.checkBox1.Size = new System.Drawing.Size(117, 17);
            this.checkBox1.TabIndex = 10;
            this.checkBox1.Text = "Full Time Employee";
            this.checkBox1.UseVisualStyleBackColor = true;
            this.formChangedComponent1.SetValueNameToMonitor(this.checkBox1, "Checked");
            // 
            // comboBox1
            // 
            this.formChangedComponent1.SetChangeEventToMonitor(this.comboBox1, "SelectedValueChanged");
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Items.AddRange(new object[] {
            "Finance",
            "Information Technology",
            "Security"});
            this.comboBox1.Location = new System.Drawing.Point(118, 76);
            this.formChangedComponent1.SetMonitorForChanges(this.comboBox1, true);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(162, 21);
            this.comboBox1.TabIndex = 12;
            this.formChangedComponent1.SetValueNameToMonitor(this.comboBox1, "SelectedValue");
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.formChangedComponent1.SetChangeEventToMonitor(this.label1, "TextChanged");
            this.label1.Location = new System.Drawing.Point(13, 13);
            this.formChangedComponent1.SetMonitorForChanges(this.label1, true);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(82, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Employee name";
            this.formChangedComponent1.SetValueNameToMonitor(this.label1, "Text");
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.formChangedComponent1.SetChangeEventToMonitor(this.label2, "TextChanged");
            this.label2.Location = new System.Drawing.Point(13, 76);
            this.formChangedComponent1.SetMonitorForChanges(this.label2, true);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(62, 13);
            this.label2.TabIndex = 11;
            this.label2.Text = "Department";
            this.formChangedComponent1.SetValueNameToMonitor(this.label2, "Text");
            // 
            // Button_WhatChanged
            // 
            this.Button_WhatChanged.Location = new System.Drawing.Point(161, 238);
            this.Button_WhatChanged.Name = "Button_WhatChanged";
            this.Button_WhatChanged.Size = new System.Drawing.Size(119, 23);
            this.Button_WhatChanged.TabIndex = 9;
            this.Button_WhatChanged.Text = "What Changed?";
            this.Button_WhatChanged.UseVisualStyleBackColor = true;
            // 
            // Button_Reset
            // 
            this.Button_Reset.Location = new System.Drawing.Point(12, 238);
            this.Button_Reset.Name = "Button_Reset";
            this.Button_Reset.Size = new System.Drawing.Size(75, 23);
            this.Button_Reset.TabIndex = 8;
            this.Button_Reset.Text = "Reset";
            this.Button_Reset.UseVisualStyleBackColor = true;
            // 
            // Form_Changetest
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(292, 273);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.checkBox1);
            this.Controls.Add(this.Button_WhatChanged);
            this.Controls.Add(this.Button_Reset);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBox_Employeename);
            this.Name = "Form_Changetest";
            this.Text = "Change Event testing";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private FormChangedComponent formChangedComponent1;
        private System.Windows.Forms.TextBox textBox_Employeename;
        private System.Windows.Forms.Label label1;
        internal System.Windows.Forms.Button Button_WhatChanged;
        internal System.Windows.Forms.Button Button_Reset;
        private System.Windows.Forms.CheckBox checkBox1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.ComboBox comboBox1;
    }
}

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
Ireland Ireland
C# / SQL Server developer
Microsoft MVP (Azure) 2017
Microsoft MVP (Visual Basic) 2006, 2007

Comments and Discussions