Click here to Skip to main content
13,096,399 members (56,420 online)
Click here to Skip to main content

Stats

58.5K views
1.3K downloads
80 bookmarked
Posted 28 Jun 2007

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)
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 (Azure) 2017
Microsoft MVP (Visual Basic) 2006, 2007

You may also be interested in...

Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170813.1 | Last Updated 26 May 2008
Article Copyright 2007 by Duncan Edwards Jones
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid