<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2190752858299680612</id><updated>2024-08-28T16:42:34.130+01:00</updated><category term="c#"/><category term="Dataset"/><category term="Visual Studio"/><category term=".net"/><category term=".net threading winforms events visual studio"/><category term="Datagridview"/><category term="Serialization"/><category term="T-SQL"/><category term="bind"/><category term="chm"/><category term="control"/><category term="ctrl key"/><category term="error constraints"/><category term="events"/><category term="help file"/><category term="multiselect"/><category term="problem"/><category term="procedure"/><category term="serializaton"/><category term="shuffle"/><category term="zorder"/><title type='text'>.net experiments</title><subtitle type='html'>Experiments with .net and microsoft technologies</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-3380980045819519407</id><published>2008-02-05T14:44:00.001+01:00</published><updated>2008-02-05T14:44:34.440+01:00</updated><title type='text'>Event override in c# (with a taste of reflection)</title><content type='html'>&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;Have you ever tried to override a event suscription in c#?&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;Let’s say you have a form with a control inherited from a button, and you want to INTERCEPT THE EVENT SUSCRIPTION.&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;For instance if you have a second button, you want that whenever somebody suscribes to the click event of this button, it also suscribes to the event click of another button or change the target event handler, or log it or whatever processing you can imagine.&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;In my example I’m going to use event suscription override to automatically use the event handler as the handler of the click of another button&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;That is, that writing this:&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;.button1.Click += &lt;span style=&quot;color: blue&quot;&gt;new&lt;/span&gt; System.&lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt;(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.button1_Click);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;Is going to be implicitly equivalent to this:&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;.button1.Click += &lt;span style=&quot;color: blue&quot;&gt;new&lt;/span&gt; System.&lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt;(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.button1_Click);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;.button2.Click += &lt;span style=&quot;color: blue&quot;&gt;new&lt;/span&gt; System.&lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt;(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.button1_Click);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;and I’m going to do this through event overriding (Full test vs2005 project can be downloaded &lt;a href=&quot;http://www.mediafire.com/?3o7wuszzd4l&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;here&lt;/span&gt;&lt;/a&gt; )&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;As you probably know, this is not possible in c# &lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;InheritedButton&lt;/span&gt; : &lt;span style=&quot;color: teal&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// That&#39;s not allowed&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;override&lt;/span&gt; Click ...&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;so we are going to use a little trick (including reflection) to simulate that.&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;First, I am going to define a new ‘EventHandler’ class that includes a virtual function to allow extension on inherited classes. &lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;Things to note:&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;1.&amp;nbsp; The constructor includes both the control and the event name you want to handle (so we can use in reflection)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;2. The class defines a operator + to keep the common event suscription sintaxis&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Collections.Generic;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Text;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Windows.Forms;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Collections;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Reflection;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;namespace&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; TestOverrideEvent&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: green; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // By Javier Alvarez de Pedro, if you use this code... well, I&#39;m glad to help you :)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; m_ctrl;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; Ctrl&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue&quot;&gt;return&lt;/span&gt; m_ctrl; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;set&lt;/span&gt; { m_ctrl = &lt;span style=&quot;color: blue&quot;&gt;value&lt;/span&gt;; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;String&lt;/span&gt; m_eventName;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;String&lt;/span&gt; EventName&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: blue&quot;&gt;return&lt;/span&gt; m_eventName; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;set&lt;/span&gt; { m_eventName = &lt;span style=&quot;color: blue&quot;&gt;value&lt;/span&gt;; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; BaseOverrideEventHandler(&lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; ctrl,&lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt; eventName)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_ctrl = ctrl;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_eventName = eventName;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;operator&lt;/span&gt; +(&lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; pbEventhandler, &lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt; handler)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// Suscribe to event&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt; eventName = pbEventhandler.m_eventName;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; ctrl = pbEventhandler.m_ctrl;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: teal&quot;&gt;EventInfo&lt;/span&gt; ei = ctrl.GetType().GetEvent(eventName);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ei.AddEventHandler(pbEventhandler.m_ctrl, handler);&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// Call for aditional operations on inherited classes&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pbEventhandler.SuscribeTasks(pbEventhandler, handler);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// Return modified event handler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;return&lt;/span&gt; pbEventhandler;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;operator&lt;/span&gt; -(&lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; pbEventhandler, &lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt; handler)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// Suscribe to event&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt; eventName = pbEventhandler.m_eventName;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; ctrl = pbEventhandler.m_ctrl;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: teal&quot;&gt;EventInfo&lt;/span&gt; ei = ctrl.GetType().GetEvent(eventName);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ei.RemoveEventHandler(pbEventhandler.m_ctrl, handler);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// Return modified event handler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;return&lt;/span&gt; pbEventhandler;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;void&lt;/span&gt; SuscribeTasks(&lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; overrideEventHandler, &lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt; eventHandler)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;Then I write a inherited class for customizing the event handling, so when you suscribe to the click event, you are also suscribing to the click of the rest of the buttons&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Collections.Generic;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Text;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Windows.Forms;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;namespace&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; TestOverrideEvent&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// By Javier Alvarez de Pedro, if you use this code... well, I&#39;m glad to help you :)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;MyOverrideEventHandler&lt;/span&gt; : &lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; MyOverrideEventHandler(&lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; ctrl)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style=&quot;color: blue&quot;&gt;base&lt;/span&gt;(ctrl, &lt;span style=&quot;color: maroon&quot;&gt;&quot;Click&quot;&lt;/span&gt;)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;void&lt;/span&gt; SuscribeTasks(&lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; overrideEventHandler, &lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt; eventHandler)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;base&lt;/span&gt;.SuscribeTasks(overrideEventHandler, eventHandler);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; ctrl = overrideEventHandler.Ctrl;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;foreach&lt;/span&gt; (&lt;span style=&quot;color: teal&quot;&gt;Control&lt;/span&gt; c &lt;span style=&quot;color: blue&quot;&gt;in&lt;/span&gt; ctrl.Parent.Controls)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;if&lt;/span&gt; (c &lt;span style=&quot;color: blue&quot;&gt;is&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;Button&lt;/span&gt; &amp;amp;&amp;amp; c != ctrl)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c.Click += eventHandler;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;And then I create a button that ‘overrides ‘ the click event&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Collections.Generic;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Text;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Windows.Forms;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; TestOverrideEvent;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;namespace&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; TestOverrideEvent&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;InheritedButton&lt;/span&gt; : &lt;span style=&quot;color: teal&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;// That&#39;s not allowed&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: green&quot;&gt;//public override Click ...&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: green; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; m_Click;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; InheritedButton()&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Click = &lt;span style=&quot;color: blue&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;MyOverrideEventHandler&lt;/span&gt;(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;BaseOverrideEventHandler&lt;/span&gt; Click&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;get&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;return&lt;/span&gt; m_Click;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;set&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_Click = &lt;span style=&quot;color: blue&quot;&gt;value&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;If you just define a form with a Inherited button and a few other buttons, suscribe ONLY to the click of the button1 and … magic! When you click the other buttons, the event is also fired! (Note that I haven’t modified the sintaxis of the suscription, you keep using a &lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;System.&lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; for suscribing)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Arial&#39;,&#39;sans-serif&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Collections.Generic;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.ComponentModel;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Data;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Drawing;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Text;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; System.Windows.Forms;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; color: blue; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;namespace&lt;/span&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt; TestOverrideEvent&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;partial&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: teal&quot;&gt;Form1&lt;/span&gt; : &lt;span style=&quot;color: teal&quot;&gt;Form&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;public&lt;/span&gt; Form1()&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.button1.Click += &lt;span style=&quot;color: blue&quot;&gt;new&lt;/span&gt; System.&lt;span style=&quot;color: teal&quot;&gt;EventHandler&lt;/span&gt;(&lt;span style=&quot;color: blue&quot;&gt;this&lt;/span&gt;.button1_Click);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue&quot;&gt;void&lt;/span&gt; button1_Click(&lt;span style=&quot;color: blue&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: teal&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: teal&quot;&gt;MessageBox&lt;/span&gt;.Show(&lt;span style=&quot;color: maroon&quot;&gt;&quot;Click 1&quot;&lt;/span&gt;);&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; line-height: normal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: &#39;Courier New&#39;; mso-fareast-font-family: &#39;Times New Roman&#39;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: &#39;Times New Roman&#39;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/3380980045819519407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/3380980045819519407' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/3380980045819519407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/3380980045819519407'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2008/02/event-override-in-c-with-taste-of.html' title='Event override in c# (with a taste of reflection)'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-6838916722277675856</id><published>2007-08-29T08:56:00.001+01:00</published><updated>2007-08-29T08:57:45.617+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="Dataset"/><category scheme="http://www.blogger.com/atom/ns#" term="Serialization"/><category scheme="http://www.blogger.com/atom/ns#" term="shuffle"/><title type='text'>Dataset serialization shuffles tables</title><content type='html'>&lt;p&gt;Yes, another serialization problem.&lt;/p&gt; &lt;p&gt;We have defined a BIG dataset, then we create a instance of it. In a certain portion of the code, we serialize it with a binary formatter, but ... surprise when we deserialize, the tables order doesn&#39;t match!&lt;/p&gt; &lt;p&gt;Well, so far I haven&#39;t had much time to investigate, but setting the remoting format to binary does the trick:&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;ProcessDataSet.RemotingFormat = SerializationFormat.Binary&lt;/font&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/6838916722277675856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/6838916722277675856' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/6838916722277675856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/6838916722277675856'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2007/08/dataset-serialization-shuffles-tables.html' title='Dataset serialization shuffles tables'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-4919021827551665977</id><published>2007-08-28T14:45:00.001+01:00</published><updated>2007-08-29T08:58:45.446+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="serializaton"/><title type='text'>Serialization of a class that inherit from HashTable (or any class that implements ISerializable)</title><content type='html'>&lt;p&gt;This is another funny problem related to serialization. Have you serialized a class and when deserialized again all the field values are set to default values? Well, check if this is your case: &lt;p&gt;If you have a class (Class1) that inherits from another one that is ISerializable (i.e. HashTable), &lt;p&gt;then you MUST write a constructor to handle SerializationInfo: &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;[Serializable]&lt;br&gt;class Class1: Hashtable&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Class1(SerializationInfo info, StreamingContext context)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : base(info, context)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Class1()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected int number;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private int othernumber;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string text; &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int OtherNumber&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return othernumber;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; othernumber = value;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Number&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return number;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = value;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br&gt;}&lt;/font&gt; &lt;p&gt;What’s the problem related to this?. Well, write a short win application with a button to test: &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;private void button1_Click(object sender, EventArgs e)&lt;br&gt;{ &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class1 obj = new Class1();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.Number = 99;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.OtherNumber = 100;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.text = &quot;hello&quot;; &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte[] serializedObject;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(); &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //formatter.FilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; formatter.Serialize(memoryStream, obj);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serializedObject = memoryStream.GetBuffer(); &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.IO.MemoryStream memoryStream2 = new System.IO.MemoryStream(serializedObject);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class1 obj2 = (Class1)formatter.Deserialize(memoryStream2);&lt;br&gt;}&lt;/font&gt; &lt;p&gt;And now, check the obj2: None of the values where properly retrieved! Why? &lt;p&gt;Well, as the Class1 class inherits from hashtable and hastable implements ISerializable, you need to write the special constructor above, but once you write the constructor, you are telling .net that you will be in charge of saving the data you really want to save… If you save no information for your fields, no data is saved when serialized, so no data is retrieved when deserialized. &lt;p&gt;The quick (and dirty ;) ) way to solve this: Use reflection to automatically traverse the properties and save them instead of write code to save them one by one: &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;[Serializable]&lt;br&gt;class Class1: Hashtable&lt;br&gt;{&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Class1(SerializationInfo info, StreamingContext context)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : base(info, context)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[] fields = this.GetFields(this);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (FieldInfo fieldInfo in fields)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Object obj = info.GetValue(fieldInfo.Name,fieldInfo.FieldType);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldInfo.SetValue(this,obj);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public override void GetObjectData(SerializationInfo info, StreamingContext context)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[] fields = this.GetFields(this);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (FieldInfo fieldInfo in fields)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; info.AddValue(fieldInfo.Name,fieldInfo.GetValue(this));&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.GetObjectData(info, context);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Class1()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected int number;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private int othernumber;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string text; &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int OtherNumber&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return othernumber;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; othernumber = value;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int Number&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return number;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number = value;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private FieldInfo[] GetFields(object obj)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[] fields =&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000a0&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fields;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;Note that I’ve include the BindingFlags I’ve added to obtain the fields. This can be modified if other kind of filters are needed.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/4919021827551665977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/4919021827551665977' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/4919021827551665977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/4919021827551665977'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2007/08/serialization-of-class-that-inherit.html' title='Serialization of a class that inherit from HashTable (or any class that implements ISerializable)'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-8951905921078868611</id><published>2007-04-27T08:22:00.000+01:00</published><updated>2008-02-05T12:25:28.729+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="control"/><category scheme="http://www.blogger.com/atom/ns#" term="zorder"/><title type='text'>Identifying if the next/s control in z order hides a given control</title><content type='html'>This is a quite simple c# class that lets identify if for a certain control, there is another above that hides the control (partially or completely, depending on the option).&lt;br /&gt;&lt;br /&gt;I&#39;ve uploaded a sample project here: &lt;a href=&quot;http://www.mediafire.com/?brjttzmxmfm&quot;&gt;Z order sample project&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here is the ZOrder class code:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.Runtime.InteropServices;&lt;br /&gt;using System.Drawing;&lt;br /&gt;&lt;br /&gt;namespace ZOrderFunctions&lt;br /&gt;{&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// Defines helper function for testing zorder relationships&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    // By Javier Alvarez, 27 april 2007&lt;br /&gt;    class ZOrder&lt;br /&gt;    {&lt;br /&gt;        #region GetWindow&lt;br /&gt;        private const int GW_HWNDNEXT = 2;&lt;br /&gt;        private const int GW_HWNDPREV = 3;&lt;br /&gt;        private const int GW_CHILD = 5;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        [DllImport(&quot;User32.dll&quot;)]&lt;br /&gt;        private static extern IntPtr GetWindow(IntPtr hwndSibling,&lt;br /&gt;                                           int wFlag);&lt;br /&gt;        //Parameters&lt;br /&gt;        //hWnd&lt;br /&gt;        //[in] Handle to a window. The window handle retrieved is relative to this window, based on the value of the uCmd parameter. &lt;br /&gt;        //uCmd&lt;br /&gt;        //[in] Specifies the relationship between the specified window and the window whose handle is to be retrieved. This parameter can be one of the following values. &lt;br /&gt;        //GW_CHILD&lt;br /&gt;        //The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows.&lt;br /&gt;        //GW_ENABLEDPOPUP&lt;br /&gt;        //Windows 2000/XP: The retrieved handle identifies the enabled popup window owned by the specified window (the search uses the first such window found using GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the retrieved handle is that of the specified window. &lt;br /&gt;        //GW_HWNDFIRST&lt;br /&gt;        //The retrieved handle identifies the window of the same type that is highest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is highest in the Z order. If the specified window is a top-level window, the handle identifies the top-level window that is highest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is highest in the Z order.&lt;br /&gt;        //GW_HWNDLAST&lt;br /&gt;        //The retrieved handle identifies the window of the same type that is lowest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is lowest in the Z order. If the specified window is a top-level window, the handle identifies the top-level window that is lowest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is lowest in the Z order.&lt;br /&gt;        //GW_HWNDNEXT&lt;br /&gt;        //The retrieved handle identifies the window below the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window below the specified window. If the specified window is a top-level window, the handle identifies the top-level window below the specified window. If the specified window is a child window, the handle identifies the sibling window below the specified window.&lt;br /&gt;        //GW_HWNDPREV&lt;br /&gt;        //The retrieved handle identifies the window above the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window above the specified window. If the specified window is a top-level window, the handle identifies the top-level window above the specified window. If the specified window is a child window, the handle identifies the sibling window above the specified window.&lt;br /&gt;        //GW_OWNER&lt;br /&gt;        //The retrieved handle identifies the specified window&#39;s owner window, if any. For more information, see Owned Windows. &lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Tells if the control is hidden by other in the z order&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name=&quot;sender&quot;&gt;Control to be checked&lt;/param&gt;&lt;br /&gt;        /// &lt;param name=&quot;partially&quot;&gt;if true, a control is returned even if it is only partially hidden, if false, the control must be completely hidden&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;If there is a control above, reference to the control &lt;/returns&gt;&lt;br /&gt;        public static Control IsHidden(Control sender, bool partially)&lt;br /&gt;        {&lt;br /&gt;            // Check preconditions&lt;br /&gt;            if (sender == null) throw new ArgumentException(&quot;IsHidden recieved null as parameter&quot;);&lt;br /&gt;&lt;br /&gt;            // &#39;Found a control&#39; flag&lt;br /&gt;            bool ret = false;&lt;br /&gt;&lt;br /&gt;            // Return value&lt;br /&gt;            Control topControl = null;&lt;br /&gt;&lt;br /&gt;            // Point to the display area rectangle&lt;br /&gt;            Rectangle senderRect = sender.DisplayRectangle; //new Rectangle(sRect.X, sRect.Y, sRect.Width, sRect.Height);            senderRect.Location.Offset(&lt;br /&gt;            senderRect.Offset(sender.Left, sender.Top);&lt;br /&gt;&lt;br /&gt;            // Iterate through higher z-order controls to see if any above the sender control&lt;br /&gt;            IntPtr currentHandler = sender.Handle  ;&lt;br /&gt;            Control currentControl = null;&lt;br /&gt;            do&lt;br /&gt;            {&lt;br /&gt;                // Get next control&lt;br /&gt;                currentHandler = GetWindow(currentHandler, GW_HWNDPREV);&lt;br /&gt;&lt;br /&gt;                if (currentHandler != IntPtr.Zero)&lt;br /&gt;                {&lt;br /&gt;                    // Get associated rectangle&lt;br /&gt;                    currentControl = Control.FromHandle(currentHandler);&lt;br /&gt;                    Rectangle currentRectangle = currentControl.DisplayRectangle;&lt;br /&gt;                    currentRectangle.Offset(currentControl.Left, currentControl.Top);&lt;br /&gt;&lt;br /&gt;                    // Select if fully contained or partially&lt;br /&gt;                    if (partially)&lt;br /&gt;                    {&lt;br /&gt;                        ret = currentControl.Visible &amp;&amp; currentRectangle.IntersectsWith(senderRect);&lt;br /&gt;                    }&lt;br /&gt;                    else&lt;br /&gt;                    {&lt;br /&gt;                        ret = currentControl.Visible &amp;&amp; currentRectangle.Contains(senderRect);&lt;br /&gt;                    }&lt;br /&gt;                    // Point to control if it matches the condition&lt;br /&gt;                    if (ret)&lt;br /&gt;                    {&lt;br /&gt;                        topControl = currentControl;&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            } while (!ret &amp;&amp; currentHandler != IntPtr.Zero);&lt;br /&gt;&lt;br /&gt;            return topControl;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Build a sample form with three buttons and add the following (or alike) code to test:&lt;br /&gt;&lt;br /&gt;    public partial class Form1 : Form&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public Form1()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Test(object sender)&lt;br /&gt;        {&lt;br /&gt;            Control top = ZOrder.IsHidden(sender as Control, true);&lt;br /&gt;            if (top != null)&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show(&quot;Handle of control above is : &quot; + top.Handle.ToString());&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show(&quot;This control is the topmost&quot;);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void button2_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Test(sender);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void button1_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Test(sender);            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void button3_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Test(sender);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Form1_Load(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            button1.Text = button1.Handle.ToString();&lt;br /&gt;            button2.Text = button2.Handle.ToString();&lt;br /&gt;            button3.Text = button3.Handle.ToString();&lt;br /&gt;        }&lt;br /&gt;    }</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/8951905921078868611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/8951905921078868611' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/8951905921078868611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/8951905921078868611'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2007/04/identifying-if-next-control-in-z-order.html' title='Identifying if the next/s control in z order hides a given control'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-4092764623959872923</id><published>2007-03-22T10:10:00.000+01:00</published><updated>2007-03-22T10:27:21.945+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bind"/><category scheme="http://www.blogger.com/atom/ns#" term="procedure"/><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><title type='text'>Visual studio 2005 T-SQL Debugging &quot;Unable to bind SQL breakpoint at this time&quot;</title><content type='html'>Did you found the &quot;Unable to bind SQL breakpoint at this time&quot; error when debugging pure T-SQL procedures (not CLR)? &lt;br /&gt;&lt;br /&gt;Today I discovered a funny &#39;feature&#39; of the Visual Studio related to T-SQL debugging (hopefully solved in the sp1...):&lt;br /&gt;&lt;br /&gt;Accordingly to one of the developers of the Visual Studio Debugger Team, there is an issue with dead connections in Server explorer: &lt;br /&gt;&lt;br /&gt;(see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=840978&amp;SiteID=1&amp;mode=1)&lt;br /&gt;&lt;br /&gt;So to be able to step into the procedures from the visual studio, you need to:&lt;br /&gt;a) Delete ALL the connections you may have created&lt;br /&gt;b) Close the Visual Studio&lt;br /&gt;c) Reopen Visual Studio&lt;br /&gt;d) Recreate the connection to the database you want to debug. Make sure credentials you use to connect belong to the sysadmin group of the SQL Server&lt;br /&gt;&lt;br /&gt;That&#39;s all folks... at least it worked for me.&lt;br /&gt;&lt;br /&gt;Anyway... first option is to install SP1 ;o)</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/4092764623959872923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/4092764623959872923' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/4092764623959872923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/4092764623959872923'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2007/03/visual-studio-2005-t-sql-debugging.html' title='Visual studio 2005 T-SQL Debugging &quot;Unable to bind SQL breakpoint at this time&quot;'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-7019671170563376297</id><published>2007-02-19T18:30:00.000+01:00</published><updated>2007-04-27T08:30:55.624+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Dataset"/><category scheme="http://www.blogger.com/atom/ns#" term="error constraints"/><title type='text'>Detailed error info for datasets filling</title><content type='html'>Tyred of the &quot;Failed to enable constraints. One&lt;br /&gt;or more rows contain values violating non-null, unique, or foreign-key&lt;br /&gt;constraints&quot;. &quot; error when filling dataset?&lt;br /&gt;&lt;br /&gt;Well, the detailed error info is buried inside the dataset (not deeply buried after all...)&lt;br /&gt;&lt;br /&gt;But for the lazy people (like me), you can add this class to whatever project you want and just call the static method in the inmediate window, passing the dataset, to see from where the error comes from...&lt;br /&gt;&lt;br /&gt;Example: DataSetDebugger.GetErrors(myDataset)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The class:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;&lt;br /&gt;namespace DataDebug&lt;br /&gt;{&lt;br /&gt;    class DataSetDebugger&lt;br /&gt;    {&lt;br /&gt;        public static void GetErrors(DataSet ds)&lt;br /&gt;        {&lt;br /&gt;            Debug.WriteLine(&quot;--- Checking errors on dataset: &#39;&quot; + ds.DataSetName + &quot;&#39;---&quot;);&lt;br /&gt;            foreach (DataTable tb in ds.Tables)&lt;br /&gt;            {&lt;br /&gt;                if (tb.HasErrors)&lt;br /&gt;                {&lt;br /&gt;                    Debug.WriteLine(&quot;    Errors found on table: &#39;&quot; + tb.TableName + &quot;&#39;&quot;);&lt;br /&gt;                    int i = 0;&lt;br /&gt;                    foreach (DataRow dr in tb.GetErrors())&lt;br /&gt;                    {                        &lt;br /&gt;&lt;br /&gt;                        Debug.WriteLine(&quot;       Errors found on row: [&quot; + i.ToString() + &quot;]:&quot;);&lt;br /&gt;                        Debug.WriteLine(&quot;          - Error description: &quot; + dr.RowError);&lt;br /&gt;                        foreach(DataColumn col in dr.GetColumnsInError())&lt;br /&gt;                        {&lt;br /&gt;                            Debug.WriteLine(&quot;          - Column: &quot; + col.ColumnName + &quot; Error: &quot; + dr.GetColumnError(col));&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        i++;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            Debug.WriteLine(&quot;--- Checking done ---&quot;);&lt;br /&gt;            Debug.WriteLine(&quot;&quot;);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/em&gt;</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/7019671170563376297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/7019671170563376297' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/7019671170563376297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/7019671170563376297'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2007/02/detailed-error-info-for-datasets.html' title='Detailed error info for datasets filling'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-3901094732026480223</id><published>2007-02-16T12:34:00.000+01:00</published><updated>2007-04-27T08:30:27.922+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ctrl key"/><category scheme="http://www.blogger.com/atom/ns#" term="Datagridview"/><category scheme="http://www.blogger.com/atom/ns#" term="multiselect"/><title type='text'>DataGridView multiselect without CTRL</title><content type='html'>One of my mates has asked my about how to enable a datagridview multiselection without pressing CTRL key (for a touch screen). I haven&#39;t tested it throughly, but here comes a (C#) possible solution:&lt;br /&gt;&lt;br /&gt;I´ve tested it only with a Datagridview configured for full row selection.&lt;br /&gt;&lt;br /&gt;Basically I hold a private collection of the rows I want to select and every time a row is pressed, it´s selected or removed accordingly&lt;br /&gt;&lt;br /&gt;The empty override method avoids selection refresh. Try to remove it and see...&lt;br /&gt;&lt;br /&gt;&lt;em&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Diagnostics;&lt;br /&gt;&lt;br /&gt;namespace MyDataGridView&lt;br /&gt;{&lt;br /&gt;    public partial class MyDataGridV : DataGridView&lt;br /&gt;    {&lt;br /&gt;        private Hashtable mySelectedRows = new Hashtable();&lt;br /&gt;&lt;br /&gt;        public MyDataGridV()&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e)&lt;br /&gt;        {&lt;br /&gt; &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnCellClick(DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (mySelectedRows.ContainsKey(e.RowIndex))&lt;br /&gt;            {&lt;br /&gt;                mySelectedRows.Remove(e.RowIndex);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                mySelectedRows.Add(e.RowIndex, this.Rows[e.RowIndex]);&lt;br /&gt;            }&lt;br /&gt;            for (int i = 0; i &lt; this.Rows.Count; i++)&lt;br /&gt;            {&lt;br /&gt;                if (mySelectedRows.Contains(i))&lt;br /&gt;                {&lt;br /&gt;                    this.SetSelectedRowCore(i, true);&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    this.SetSelectedRowCore(i, false);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            Debug.Assert(this.SelectedRows.Count == mySelectedRows.Count, &quot;Selected rows number don´t match&quot;);&lt;br /&gt;            base.OnCellClick(e);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/em&gt;</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/3901094732026480223/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/3901094732026480223' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/3901094732026480223'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/3901094732026480223'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2007/02/datagridview-multiselect-without-ctrl.html' title='DataGridView multiselect without CTRL'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-145240873894538600</id><published>2006-11-29T11:04:00.000+01:00</published><updated>2007-04-27T08:30:06.023+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="chm"/><category scheme="http://www.blogger.com/atom/ns#" term="help file"/><category scheme="http://www.blogger.com/atom/ns#" term="problem"/><title type='text'>chm problems</title><content type='html'>This has nothing to do with .net ... but interesting.&lt;br /&gt;&lt;br /&gt; Today I realized that no .chm file opened in my computer. It just tried to open the process and they closed without further clues.&lt;br /&gt;&lt;br /&gt;Thanks to &lt;a name=&quot;MJs&quot;&gt;&lt;/a&gt;MJ&#39;s Help Diagnostics tool &lt;a href=&quot;http://www.helpware.net/downloads/MJsDiag.zip&quot;&gt;http://www.helpware.net/downloads/MJsDiag.zip&lt;/a&gt;&lt;br /&gt;I found, under the &lt;em&gt;HTML Help Run-time Components &lt;/em&gt;section this...&lt;br /&gt;&lt;br /&gt;File not found: D:\WINDOWS\system32\hhctrl.ocx&lt;br /&gt;&lt;br /&gt;I don´t know what the *** happened to this file, but after copying it again, it worked fine.</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/145240873894538600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/145240873894538600' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/145240873894538600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/145240873894538600'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2006/11/chm-problems.html' title='chm problems'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2190752858299680612.post-5778817536961899330</id><published>2006-11-28T17:54:00.000+01:00</published><updated>2007-04-27T08:29:39.590+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term=".net threading winforms events visual studio"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="events"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><title type='text'>Winforms applications, threads and events</title><content type='html'>&lt;span style=&quot;font-family:arial;&quot;&gt;Ok here I go with my first entry with a very short sample I wrote for a mate to let him play with threads on winforms, you know... threads are funny!&lt;br /&gt;&lt;br /&gt;Windows have a very special way to use threads on winforms as all &lt;strong&gt;the controls are bounded to the thread that creates them&lt;/strong&gt;, so whenever you are going to modify a control´s property, you need to make sure you are doing from the right thread.&lt;br /&gt;&lt;br /&gt;A common problem is that you launch a thread to perform async processing and at a certain point, the thread reaches some condition and launches an event.&lt;br /&gt;In the event handler you want to modify some of the user interface properties but... you need to switch to the right thread. That´s where &lt;em&gt;InvokeRequired&lt;/em&gt; and &lt;em&gt;Invoke&lt;/em&gt; come to help.&lt;br /&gt;&lt;br /&gt;InvokeRequired basically compares the thread identity to which the control you are testing is bounded with the thread identity of the running thread. If they are different, it returns true. In that &lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;case, you must use Invoke to call a delegate in the right thread. &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;(Well it´s a little bit more complicated... Invoke can return false if the handle of the control hasn´t been created. If you are in that case, be careful of performing any operation as the control can be created bounded to the wrong thread. Check IsHandleCreated and CreateControl functions to learn more about it...)&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;By the way... playing with the delays you can realize that if the secondary thread finishes when the main thread is still busy, the invoke sentence&lt;/span&gt; is not executed till the main thread is finished. The reason for this is easy: The main thread is running continuosly a loop (you can see it in the call stack window) and the invoke sentence puts a special message to be consumed by that loop.&lt;br /&gt;Only when the loop runs the next iteration, the invoke message is consumed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here it comes the mini-sample... copy paste it to a winforms code file to play with it&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;namespace win_threadDemo&lt;br /&gt;{&lt;br /&gt;public partial class Form1 : Form&lt;br /&gt;{&lt;br /&gt;private delegate void TextDelegate(string text);&lt;br /&gt;private event TextDelegate EventDelegate;&lt;br /&gt;&lt;br /&gt;public Form1()&lt;br /&gt;{&lt;br /&gt;InitializeComponent();&lt;br /&gt;this.EventDelegate += new TextDelegate(this.OnEvent);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;label1.Text = &quot;&quot;;&lt;br /&gt;label2.Text = &quot;&quot;;&lt;br /&gt;if (Thread.CurrentThread.Name == null)&lt;br /&gt;{&lt;br /&gt;Thread.CurrentThread.Name = &quot;Main thread&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Thread t = new Thread(new ThreadStart(SecondaryThreadOperation));&lt;br /&gt;t.Name = &quot;Secondary thread&quot;;&lt;br /&gt;t.Start();&lt;br /&gt;// Long running operation on main thread&lt;br /&gt;Thread.Sleep(15000);&lt;br /&gt;label2.Text = &quot;Main thread finished&quot;;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private void SecondaryThreadOperation()&lt;br /&gt;{&lt;br /&gt;//Some long task&lt;br /&gt;Thread.Sleep(10000);&lt;br /&gt;//Raise event if any suscriber is present&lt;br /&gt;if (this.EventDelegate != null)&lt;br /&gt;{&lt;br /&gt;this.EventDelegate(&quot;Secondary thread finished&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void OnEvent(string text)&lt;br /&gt;{&lt;br /&gt;if (label1.InvokeRequired)&lt;br /&gt;{&lt;br /&gt;label1.Invoke(new TextDelegate(this.ChangeText), new object[] { text });&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;this.ChangeText(text);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void ChangeText(string text)&lt;br /&gt;{&lt;br /&gt;label1.Text = text + &quot; modified on &quot; + Thread.CurrentThread.Name;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;/em&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://netexperiments.blogspot.com/feeds/5778817536961899330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/2190752858299680612/5778817536961899330' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/5778817536961899330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2190752858299680612/posts/default/5778817536961899330'/><link rel='alternate' type='text/html' href='http://netexperiments.blogspot.com/2006/11/winforms-applications-threads-and.html' title='Winforms applications, threads and events'/><author><name>Jadepe</name><uri>http://www.blogger.com/profile/08126317328641805690</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>