Click here to Skip to main content
15,881,852 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 90.5K   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)
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.Label_Name = New System.Windows.Forms.Label
        Me.TextBox_Name = New System.Windows.Forms.TextBox
        Me.Label_Address = New System.Windows.Forms.Label
        Me.TextBox_Address = New System.Windows.Forms.TextBox
        Me.Label_Currency = New System.Windows.Forms.Label
        Me.TextBox_Currency = New System.Windows.Forms.TextBox
        Me.Button_Reset = New System.Windows.Forms.Button
        Me.Button_WhatChanged = New System.Windows.Forms.Button
        Me.ComboBox_Country = New System.Windows.Forms.ComboBox
        Me.CheckBox1 = New System.Windows.Forms.CheckBox
        Me.FormChangedComponent1 = New Form_Change_Control_Test.FormChangedComponent(Me.components)
        Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
        Me.SuspendLayout()
        '
        'Label_Name
        '
        Me.Label_Name.AutoSize = True
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.Label_Name, "")
        Me.Label_Name.Location = New System.Drawing.Point(12, 9)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.Label_Name, False)
        Me.Label_Name.Name = "Label_Name"
        Me.Label_Name.Size = New System.Drawing.Size(38, 13)
        Me.Label_Name.TabIndex = 0
        Me.Label_Name.Text = "Name:"
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.Label_Name, Nothing)
        '
        'TextBox_Name
        '
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.TextBox_Name, "TextChanged")
        Me.TextBox_Name.Location = New System.Drawing.Point(56, 6)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.TextBox_Name, True)
        Me.TextBox_Name.Name = "TextBox_Name"
        Me.TextBox_Name.Size = New System.Drawing.Size(387, 20)
        Me.TextBox_Name.TabIndex = 1
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.TextBox_Name, "Text")
        '
        'Label_Address
        '
        Me.Label_Address.AutoSize = True
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.Label_Address, "")
        Me.Label_Address.Location = New System.Drawing.Point(12, 47)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.Label_Address, False)
        Me.Label_Address.Name = "Label_Address"
        Me.Label_Address.Size = New System.Drawing.Size(48, 13)
        Me.Label_Address.TabIndex = 2
        Me.Label_Address.Text = "Address:"
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.Label_Address, Nothing)
        '
        'TextBox_Address
        '
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.TextBox_Address, "TextChanged")
        Me.TextBox_Address.Location = New System.Drawing.Point(66, 47)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.TextBox_Address, True)
        Me.TextBox_Address.Multiline = True
        Me.TextBox_Address.Name = "TextBox_Address"
        Me.TextBox_Address.Size = New System.Drawing.Size(377, 148)
        Me.TextBox_Address.TabIndex = 3
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.TextBox_Address, "Text")
        '
        'Label_Currency
        '
        Me.Label_Currency.AutoSize = True
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.Label_Currency, "")
        Me.Label_Currency.Location = New System.Drawing.Point(12, 213)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.Label_Currency, False)
        Me.Label_Currency.Name = "Label_Currency"
        Me.Label_Currency.Size = New System.Drawing.Size(52, 13)
        Me.Label_Currency.TabIndex = 4
        Me.Label_Currency.Text = "Currency:"
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.Label_Currency, Nothing)
        '
        'TextBox_Currency
        '
        Me.TextBox_Currency.AutoCompleteCustomSource.AddRange(New String() {"AUD", "GBP", "USD", "JPY"})
        Me.TextBox_Currency.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
        Me.TextBox_Currency.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.TextBox_Currency, "TextChanged")
        Me.TextBox_Currency.Location = New System.Drawing.Point(70, 210)
        Me.TextBox_Currency.MaxLength = 3
        Me.FormChangedComponent1.SetMonitorForChanges(Me.TextBox_Currency, True)
        Me.TextBox_Currency.Name = "TextBox_Currency"
        Me.TextBox_Currency.Size = New System.Drawing.Size(65, 20)
        Me.TextBox_Currency.TabIndex = 5
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.TextBox_Currency, "Text")
        '
        'Button_Reset
        '
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.Button_Reset, "")
        Me.Button_Reset.Location = New System.Drawing.Point(70, 236)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.Button_Reset, False)
        Me.Button_Reset.Name = "Button_Reset"
        Me.Button_Reset.Size = New System.Drawing.Size(75, 23)
        Me.Button_Reset.TabIndex = 6
        Me.Button_Reset.Text = "Reset"
        Me.Button_Reset.UseVisualStyleBackColor = True
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.Button_Reset, Nothing)
        '
        'Button_WhatChanged
        '
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.Button_WhatChanged, "")
        Me.Button_WhatChanged.Location = New System.Drawing.Point(324, 238)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.Button_WhatChanged, False)
        Me.Button_WhatChanged.Name = "Button_WhatChanged"
        Me.Button_WhatChanged.Size = New System.Drawing.Size(119, 23)
        Me.Button_WhatChanged.TabIndex = 7
        Me.Button_WhatChanged.Text = "What Changed?"
        Me.Button_WhatChanged.UseVisualStyleBackColor = True
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.Button_WhatChanged, Nothing)
        '
        'ComboBox_Country
        '
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.ComboBox_Country, "SelectedValueChanged")
        Me.ComboBox_Country.FormattingEnabled = True
        Me.ComboBox_Country.Items.AddRange(New Object() {"Antigua", "Barbados", "Canada", "United Kingdom"})
        Me.ComboBox_Country.Location = New System.Drawing.Point(197, 213)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.ComboBox_Country, True)
        Me.ComboBox_Country.Name = "ComboBox_Country"
        Me.ComboBox_Country.Size = New System.Drawing.Size(246, 21)
        Me.ComboBox_Country.TabIndex = 8
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.ComboBox_Country, "SelectedIndex")
        '
        'CheckBox1
        '
        Me.CheckBox1.AutoSize = True
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.CheckBox1, "CheckedChanged")
        Me.CheckBox1.Location = New System.Drawing.Point(197, 241)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.CheckBox1, True)
        Me.CheckBox1.Name = "CheckBox1"
        Me.CheckBox1.Size = New System.Drawing.Size(81, 17)
        Me.CheckBox1.TabIndex = 9
        Me.CheckBox1.Text = "CheckBox1"
        Me.CheckBox1.UseVisualStyleBackColor = True
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.CheckBox1, "Checked")
        '
        'DateTimePicker1
        '
        Me.FormChangedComponent1.SetChangeEventToMonitor(Me.DateTimePicker1, "ValueChanged")
        Me.DateTimePicker1.Location = New System.Drawing.Point(197, 255)
        Me.FormChangedComponent1.SetMonitorForChanges(Me.DateTimePicker1, True)
        Me.DateTimePicker1.Name = "DateTimePicker1"
        Me.DateTimePicker1.Size = New System.Drawing.Size(109, 20)
        Me.DateTimePicker1.TabIndex = 10
        Me.FormChangedComponent1.SetValueNameToMonitor(Me.DateTimePicker1, "Value")
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(455, 273)
        Me.Controls.Add(Me.DateTimePicker1)
        Me.Controls.Add(Me.CheckBox1)
        Me.Controls.Add(Me.ComboBox_Country)
        Me.Controls.Add(Me.Button_WhatChanged)
        Me.Controls.Add(Me.Button_Reset)
        Me.Controls.Add(Me.TextBox_Currency)
        Me.Controls.Add(Me.Label_Currency)
        Me.Controls.Add(Me.TextBox_Address)
        Me.Controls.Add(Me.Label_Address)
        Me.Controls.Add(Me.TextBox_Name)
        Me.Controls.Add(Me.Label_Name)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents Label_Name As System.Windows.Forms.Label
    Friend WithEvents TextBox_Name As System.Windows.Forms.TextBox
    Friend WithEvents Label_Address As System.Windows.Forms.Label
    Friend WithEvents TextBox_Address As System.Windows.Forms.TextBox
    Friend WithEvents Label_Currency As System.Windows.Forms.Label
    Friend WithEvents TextBox_Currency As System.Windows.Forms.TextBox
    Friend WithEvents Button_Reset As System.Windows.Forms.Button
    Friend WithEvents Button_WhatChanged As System.Windows.Forms.Button
    Friend WithEvents FormChangedComponent1 As Form_Change_Control_Test.FormChangedComponent
    Friend WithEvents ComboBox_Country As System.Windows.Forms.ComboBox
    Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
    Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker

End Class

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