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

Form Changed Control

, 26 May 2008
A component that allows you to monitor all the controls on the form and list any that have changed (for dirty checking)
formchangecontroltest_csharp_src.zip
Form Change Control Test CSharp
bin
Debug
Properties
Settings.settings
formchangecontrol_src.zip
Form Change Control Test
Form Change Control Test
bin
Debug
Form Change Control Test.exe
Form Change Control Test.vbproj.user
My Project
Application.myapp
Settings.settings
Form Change Control Test.suo
Public Class Form1

    Private Sub Button_Reset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_Reset.Click
        Me.FormChangedComponent1.ResetDirtyFlags()
    End Sub




    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()


    End Sub



    Private Sub Button_WhatChanged_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_WhatChanged.Click

        Dim s As New System.Text.StringBuilder
        For Each f As Control In Me.FormChangedComponent1.ControlsThatHaveChanged
            s.AppendLine(f.Name)
        Next
        If s.Length > 0 Then
            MessageBox.Show(s.ToString, "Controls that have changed", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Else
            MessageBox.Show("Nothing has changed", "Controls that have changed", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

    End Sub

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged

    End Sub

    Private Sub FormChangedComponent1_FormControlChanged(ByVal sender As Object, ByVal e As FormChangedEventArgs) Handles FormChangedComponent1.FormControlChanged
        If TypeOf e.ControlChanged Is TextBox Then
            If e.Changed Then
                e.ControlChanged.BackColor = Color.Yellow
            Else
                e.ControlChanged.BackColor = Color.White
            End If
        End If
    End Sub
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)

Share

About the Author

Duncan Edwards Jones
Software Developer (Senior)
Ireland Ireland
C# / SQL Server developer
Microsoft MVP 2006, 2007
Visual Basic .NET
Follow on   Twitter   LinkedIn

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 26 May 2008
Article Copyright 2007 by Duncan Edwards Jones
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid