<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Quick and dirty &#8220;dirty checking&#8221; for Windows form, C#</title>
	<atom:link href="http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-and-dirty-dirty-checking-for-windows-form-c</link>
	<description></description>
	<lastBuildDate>Sun, 06 May 2012 18:08:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Guillaume JAY</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-49</link>
		<dc:creator>Guillaume JAY</dc:creator>
		<pubDate>Tue, 30 Mar 2010 11:22:11 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-49</guid>
		<description>This is a very good post. As you said, a straight forward time saver. This should go to the new blog.

Anthony, I&#039;d like to see your whole class.

email guillaume(dot)jay(at)gmail(dot)com

Thanks !</description>
		<content:encoded><![CDATA[<p>This is a very good post. As you said, a straight forward time saver. This should go to the new blog.</p>
<p>Anthony, I&#8217;d like to see your whole class.</p>
<p>email guillaume(dot)jay(at)gmail(dot)com</p>
<p>Thanks !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guest</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-45</link>
		<dc:creator>Guest</dc:creator>
		<pubDate>Wed, 17 Mar 2010 08:59:52 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-45</guid>
		<description>All this is handled on text change event of a textbox or selected index changed of drop downs. as i am assigning values to controls on grid cell double click, that time also the change event get fired, i only want to track that is user made some changes in existing values or not. then only i want to prompt to save changes.
can anyone guide me?</description>
		<content:encoded><![CDATA[<p>All this is handled on text change event of a textbox or selected index changed of drop downs. as i am assigning values to controls on grid cell double click, that time also the change event get fired, i only want to track that is user made some changes in existing values or not. then only i want to prompt to save changes.<br />
can anyone guide me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-43</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Thu, 11 Mar 2010 13:07:46 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-43</guid>
		<description>I implemented a similary is dirty logic but it is dynamic and based on the event.  It uses some reflection so it may be a bit slower then your implementation, but it allows you to add new events without code changes.  Let me know what you think:

private List _dirtyEvents = new List();
            _dirtyEvents.Add(new DirtyEvent(&quot;TextChanged&quot;));
            _dirtyEvents.Add(new DirtyEvent(&quot;SelectedIndexChanged&quot;));

        private void recurseControls(Control.ControlCollection Controls)
        {
            foreach (Control c in Controls)
            {
                if (c is INotifyPropertyChanged)
                {
                    ((INotifyPropertyChanged)c).PropertyChanged += new PropertyChangedEventHandler(DirtyFormBase_PropertyChanged);

                }
                for (int i = 0; i &lt; _dirtyEvents.Count; i++)
                {
                    EventInfo ei = c.GetType().GetEvent(_dirtyEvents[i].EventName);
                    if (ei != null)
                    {
                        Delegate textChangedDelegate = Delegate.CreateDelegate(ei.EventHandlerType, typeof(DirtyFormBase).GetMethod(&quot;GenericHandler&quot;, BindingFlags.Static &#124; BindingFlags.NonPublic &#124; BindingFlags.IgnoreCase));
                        ei.AddEventHandler(c, textChangedDelegate);
                    }
                }

                if (c.HasChildren)
                    recurseControls(c.Controls);
            }
        }

        private static void GenericHandler(object sender, EventArgs args)
        {
            DirtyFormBase form = (DirtyFormBase)((Control)sender).FindForm();
            if (!form.SuspendIsDirtyCheck)
            {
                form.IsDirty = true;
            }
        }


This is a bit more code as it is a base class for all forms that need dirty logic.  If you are interested let me know and I will e-mail the class.</description>
		<content:encoded><![CDATA[<p>I implemented a similary is dirty logic but it is dynamic and based on the event.  It uses some reflection so it may be a bit slower then your implementation, but it allows you to add new events without code changes.  Let me know what you think:</p>
<p>private List _dirtyEvents = new List();<br />
            _dirtyEvents.Add(new DirtyEvent(&#8220;TextChanged&#8221;));<br />
            _dirtyEvents.Add(new DirtyEvent(&#8220;SelectedIndexChanged&#8221;));</p>
<p>        private void recurseControls(Control.ControlCollection Controls)<br />
        {<br />
            foreach (Control c in Controls)<br />
            {<br />
                if (c is INotifyPropertyChanged)<br />
                {<br />
                    ((INotifyPropertyChanged)c).PropertyChanged += new PropertyChangedEventHandler(DirtyFormBase_PropertyChanged);</p>
<p>                }<br />
                for (int i = 0; i &lt; _dirtyEvents.Count; i++)<br />
                {<br />
                    EventInfo ei = c.GetType().GetEvent(_dirtyEvents[i].EventName);<br />
                    if (ei != null)<br />
                    {<br />
                        Delegate textChangedDelegate = Delegate.CreateDelegate(ei.EventHandlerType, typeof(DirtyFormBase).GetMethod(&#8220;GenericHandler&#8221;, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.IgnoreCase));<br />
                        ei.AddEventHandler(c, textChangedDelegate);<br />
                    }<br />
                }</p>
<p>                if (c.HasChildren)<br />
                    recurseControls(c.Controls);<br />
            }<br />
        }</p>
<p>        private static void GenericHandler(object sender, EventArgs args)<br />
        {<br />
            DirtyFormBase form = (DirtyFormBase)((Control)sender).FindForm();<br />
            if (!form.SuspendIsDirtyCheck)<br />
            {<br />
                form.IsDirty = true;<br />
            }<br />
        }</p>
<p>This is a bit more code as it is a base class for all forms that need dirty logic.  If you are interested let me know and I will e-mail the class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-33</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Mon, 13 Apr 2009 23:32:28 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-33</guid>
		<description>Seems to work like a charm!  Thanks!  You saved me a few hours (possible much more) with this snippet.</description>
		<content:encoded><![CDATA[<p>Seems to work like a charm!  Thanks!  You saved me a few hours (possible much more) with this snippet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-32</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Mon, 13 Apr 2009 22:24:04 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-32</guid>
		<description>Figured it out.  Instead of the handler you have above, using:

void InputControls_OnChange(object sender, EventArgs e)

does the trick.  I&#039;ll update you with anything else I find to round out your post.  Cheers!</description>
		<content:encoded><![CDATA[<p>Figured it out.  Instead of the handler you have above, using:</p>
<p>void InputControls_OnChange(object sender, EventArgs e)</p>
<p>does the trick.  I&#8217;ll update you with anything else I find to round out your post.  Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-31</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Mon, 13 Apr 2009 22:19:54 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-31</guid>
		<description>Hmm, trying to work out an issue with your code.  I get a &quot;No overload for &#039;InputControls_OnChange&#039; matches delegate &#039;System.EventHandler&quot; error.  Still debugging it....using .net 2.0.  Any clue?</description>
		<content:encoded><![CDATA[<p>Hmm, trying to work out an issue with your code.  I get a &#8220;No overload for &#8216;InputControls_OnChange&#8217; matches delegate &#8216;System.EventHandler&#8221; error.  Still debugging it&#8230;.using .net 2.0.  Any clue?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://rayli.net/blog/2008/07/quick-and-dirty-dirty-checking-for-windows-form-c/comment-page-1/#comment-30</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Mon, 13 Apr 2009 21:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://rayli.net/blog/?p=67#comment-30</guid>
		<description>Thanks, I think I&#039;ll steal this for my own nefarious purposes.

Actually, I&#039;m going to use this to detect the &#039;isDirty&#039; on each tab change (36 tabs, 300+ controls, yes, I know...)

Thanks for providing the code!</description>
		<content:encoded><![CDATA[<p>Thanks, I think I&#8217;ll steal this for my own nefarious purposes.</p>
<p>Actually, I&#8217;m going to use this to detect the &#8216;isDirty&#8217; on each tab change (36 tabs, 300+ controls, yes, I know&#8230;)</p>
<p>Thanks for providing the code!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

