<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="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" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-9210426025253654417</atom:id><lastBuildDate>Thu, 24 Oct 2024 21:23:19 +0000</lastBuildDate><category>C#</category><category>Attributes</category><category>Parsing</category><category>XML</category><title>C# Mentor</title><description>Let&#39;s share the joy of winning.</description><link>http://csharpmentor.blogspot.com/</link><managingEditor>noreply@blogger.com (C# Mentor)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-8750578789346487506</guid><pubDate>Sat, 24 Dec 2011 08:28:00 +0000</pubDate><atom:updated>2011-12-24T00:28:47.295-08:00</atom:updated><title>Parsing tweet with Regex in C#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;p&gt;
This is a simple snippet which takes raw tweet text and converts it into a formatted tweet. Formatted tweet contains links to user handles, Links and Hashtags&lt;br /&gt;
&lt;/p&gt;
&lt;script src=&quot;https://gist.github.com/1516800.js&quot;&gt; 
&lt;/script&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2011/12/parsing-twit-with-regex-in-c.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-124311129036175435</guid><pubDate>Sun, 24 May 2009 09:35:00 +0000</pubDate><atom:updated>2012-11-18T20:30:01.073-08:00</atom:updated><title>Get RGB Color at a Point in an Image with C#.Net</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
It is very simple to get RGB Color at specific point in an image. For this purpose we need to include System.Drawing Namespace in our code.&lt;br /&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 20px; overflow: auto; padding: 5px;&quot;&gt;&lt;pre style=&quot;background-color: #fbfbfb; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px; margin: 0em; width: 100%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System.Drawing;&lt;/pre&gt;
&lt;/pre&gt;
Steps as below:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Define a point at which, you want to find the color.  &lt;/li&gt;
&lt;li&gt;Get the image loaded. &lt;/li&gt;
&lt;li&gt;Use method GetPixel from Image class instance to get color at a point.   &lt;/li&gt;
&lt;/ul&gt;
&lt;pre style=&quot;background-color: #fbfbfb; border: 1px solid rgb(206, 206, 206); min-height: 20px; overflow: auto; padding: 5px;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Bitmap&lt;/span&gt;&amp;nbsp;img&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Image&lt;/span&gt;.FromFile(@&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&amp;lt;&lt;image_file_path&gt;Image_file_path&amp;gt;&quot;&lt;/image_file_path&gt;&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;as&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Bitmap&lt;/span&gt;;
&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Color&lt;/span&gt;&amp;nbsp;colorAtPoint&amp;nbsp;=&amp;nbsp;img.GetPixel(10,&amp;nbsp;10);&lt;/pre&gt;
This is simple method getting color at a point.&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/get-rgb-color-at-point-in-image-with.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-8441353030240763408</guid><pubDate>Sat, 23 May 2009 07:46:00 +0000</pubDate><atom:updated>2009-05-23T07:50:32.447-07:00</atom:updated><title>How to create PowerPoint add in with C#.Net</title><description>&lt;p&gt;Add-in helps us by automating our daily routine work. So let us make simple one.&lt;br /&gt;Create a project of type Shared add-in Visual Studio as shown in a below snapshot.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAsj_vYmSiO_BBKOKVADJLynWcHnKNiVMTndMTry7ccGc0aygIHbD5JWjyStxHsvczz57Vty1WrRVY_gf1nS2_Sj1aXcQuBfT7FmIfpvfkVZzXSt6UdUhFTBM1iOf1gekGfCwpSMp7yFjR/s1600-h/Step%201%5B14%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;Step 1&quot; alt=&quot;Step 1&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpJnBrwOVrol2WEvMcJsTw_kXtN1IEzhpoQsv2qyx7Am3FT-LmDJy-rV_10DKBiezoLMzwI4x9MS2N5w-W_m7HLuLDegYen-76DuKbPYKDinZfBP7Xq02fSY7G8ZgxvmCu6K323lXHUZpl/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;353&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click Ok. After clicking a wizard will appear as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtqgLsefHFKuX_gLPI42W1RD77MitNaoz8sLePYsmorJWwdxnfSrvbhyqfecgqlngXFI8w5Wr5uiYtb6TTeBZw19OMvHxpKuYgYCG1JFfyDaP82p6-th8XdBeZvBtHpz3O2_nU535Q-Or7/s1600-h/step%202%5B12%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;step 2&quot; alt=&quot;step 2&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_Q7w7VnIL29JPkibs_wIFBI-duTgi0R2nPjn3dseb40qY6qVVyPo59HtxGO4KzF7jNVpwVWSmqGkV9XKbELCXhexdAm3YuSUf7D-PhETTPBagkoEftZxS1lDuEOZ6WvFhG3vrSASjhhTF/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;392&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click next to a language of you choice for development of Add-in. You can select any of the available languages but here, I have selected C# as my preferred language for development of Add-in.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzytEeRRlvRVbDYZxrd89YCeB2dGr5GTcy6V3H2Z0qwyWK9dbH5k7NwOmUPS_e1WBdf-Cn8arvb1WfBvWXH8fleMKr9Rupcdb1aOVsK7PNnizkOgNDpT9C7UYNoxqqU2-luVbD3g83cro/s1600-h/step%203%5B3%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;step 3&quot; alt=&quot;step 3&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh75EEFw4ePPkrTMbfNVUkpR6yuJZZEz2HxqniJK6py4l0il3M04MYo0Jd2l9J0DIDNn35wb_ZClNA31U-X1jCjNY5dy7fW_cfbj80sQdHWNOZenWALEiWkfrYwcitd3NDreCKhM4NGOM9c/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;392&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As we are creating add-in for PowerPoint our scope will be only PowerPoint. So Check the Microsoft PowerPoint option only leaving all other unchecked as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyoRwFcMuPGe55SkSbHE57rdwAN_yKzUiMA1PEKg0w89YKBJ3fRnc3KTQekDQfgMCgOjmTFghbfvxf9q9N_xakRL1MoU8BbGGpWxW42jh5oQsmLo80i7dirGdLdyg09EfNCcB3STWV9XU1/s1600-h/step%204%5B9%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;step 4&quot; alt=&quot;step 4&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSXiKTsfMps4OZuZW6MhCbYJGZPAwA9WG9zrQM68LalO4YxyXtIjj75llpeVy8bsTIlW9au2FinMNRuuKOM6PVI_F3XqlebbRevL_EN8sfcuzrajLmzNXuMEUXoryAzBqirV0TXX1SUVB9/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;392&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Give a name and description for add-in. We will call our add-in as &quot;Solo Addin&quot; and add a sample description as &quot;Sample Solo Addin&quot;&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggjbMBljpYpyBWrxapjzeW9njXj2zjM88k29LQDMthce3AxeXlCdCJK9uYseVldEydcLTI6UZZPOWlLttGgZF12j0LlaX9Q8E3pc19nERnl1WK4nQa0_EElUmqxpX_cOLRRtvzTrWW_LzO/s1600-h/step%205%5B9%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;step 5&quot; alt=&quot;step 5&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi71pHU0uXSrHwg66alOH_WEMi1m6mD6WJU6UdZSLyYa6Sg6vROEHRsiA71e_xqYUdM3sVdRzOAq3ArkvZbhIWuxpYIsQnCYVPaPTj4w09jKX2ujbaUhacd9W9xHOeG0gLEeaYsqHLQcFjc/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;392&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Choose options for your add-in loading. We will check first option to suggest that PowerPoint should load our add-in when it loads. Second option suggests that the add-in will be available to all users on a machine. You can change this option in deployment deploying.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQYIgBtmM6z54BMU9MC2RHIW7xsyMyTMCS8W94i0HLQJAirAnIC3RgkJBpBoHujqQAcVcSHzO3-oueTGrmXa_hWlKbFx3hem5nGPguUJ7q3GZ1mVQwKRkj1PWZbNhhzd4ea6eOdY-RmytZ/s1600-h/step%206%5B9%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;step 6&quot; alt=&quot;step 6&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiixS8i-639_gwCIecIA6Hmp1pXC2rP4yGXz8yGgzZtEMJnE8uhpi11hFHyIqcKkVGmZVQuKXs3wFfkLtG0DtW9UzeJ5iqRTVFm1uHExiD1KPsAeB5b-BJHZM8By1vH5zKdcrwdCzkptM2W/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;392&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Next screen shows summary of all the steps we have gone through.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg79FrkkoEgc5fHGphhqbjx6x97c2trytQex19-L7F7UPx_p8OJyd3NEKK1qEK2FnbsB-FouIg-KZU-RxPvx8XMdjyRMVLoXyueNHgv1jwwyJ-BzxYsHiiUwD8snl5lBwDwcWOB04g_9f4O/s1600-h/step%207%5B9%5D.jpg&quot;&gt;&lt;img style=&quot;border: 0px none ; display: inline;&quot; title=&quot;step 7&quot; alt=&quot;step 7&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNEkRKH16DQb4BiqYvi3Axsh1ieXokZbOA8IQs7FJlHAkNNwldoAo9hBWI5cHcOdGbVPqX1IJKisT2KEkQPibPQnYTqT65OUg0Gnbo2k77dXySr7sfDRaNidfNcG26BRwm5p20Pm0sO1tB/?imgmax=800&quot; width=&quot;504&quot; border=&quot;0&quot; height=&quot;392&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click on Finish button and that&#39;s all. This will create all the necessary framework and code to get started with.&lt;/p&gt;  &lt;p&gt;We have main &lt;strong&gt;Connect&lt;/strong&gt; class which will be a mediator between the code we are going to write and PowerPoint. Connect Class will have a unique GUID for an add-in to differentiate between add-ins or to uniquely identify an add-in. You Connect class GUID line will look like the below one.&lt;/p&gt;  &lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 20px;&quot;&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;[GuidAttribute(&quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;85D322E5-B30F-48EB-83A4-CB3CD133010F&lt;/span&gt;&quot;), ProgId(&quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;Solo.Connect&lt;/span&gt;&quot;)] &lt;/pre&gt;&lt;/pre&gt;Connect class has main Five event&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;OnConnection&lt;/strong&gt; - fires immediately after Connect Constructor&lt;/li&gt;&lt;li&gt;&lt;strong&gt;OnDisconnection&lt;/strong&gt; - fires after add-in shutdown&lt;/li&gt;&lt;li&gt;&lt;strong&gt;OnAddInsUpdate&lt;/strong&gt; - fires when add-in updates&lt;/li&gt;&lt;li&gt;&lt;strong&gt;OnStartupComplete&lt;/strong&gt; - fires when loading is complete. We will initialize the add-in here.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;OnBeginShutdown&lt;/strong&gt; - fires when host application begins to shutdown. We will do cleanup things here.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;So for now we will just show a &lt;span style=&quot;font-style: italic;&quot;&gt;MessageBox &lt;/span&gt;to know that we are on track. Add reference of &lt;span style=&quot;font-weight: bold;&quot;&gt;System.Windows.Forms dll&lt;/span&gt; to the project to get &lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;MessageBox &lt;/span&gt;work. Add using statement to your Connect class&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 20px;&quot;&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;using&lt;/span&gt; System.Windows.Forms;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;Show &lt;span style=&quot;font-style: italic;&quot;&gt;MessageBox &lt;/span&gt;on &lt;span style=&quot;font-weight: bold;&quot;&gt;OnStartupComplete &lt;/span&gt;event.&lt;br /&gt;&lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 20px;&quot;&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;///      &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;Implements&lt;/span&gt; the OnStartupComplete method &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;of&lt;/span&gt; the IDTExtensibility2 &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;interface&lt;/span&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;///      Receives notification that the host application has completed loading.&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;/// &amp;lt;param term=&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&#39;custom&#39;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;///      Array &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;of&lt;/span&gt; parameters that are host application specific.&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;/// &amp;lt;/param&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;/// &amp;lt;seealso &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: rgb(0, 128, 0);&quot;&gt;&#39;IDTExtensibility2&#39; /&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; void OnStartupComplete(ref System.Array custom)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;{&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;     MessageBox.Show(&quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;Hello World!&lt;/span&gt;&quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;}&lt;/pre&gt;&lt;/pre&gt;Build add-in project, Open PowerPoint, and you should get an MessageBox saying &quot;Hello World!&quot;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Conclusion:&lt;/span&gt;&lt;br /&gt;This post show how to go get started with PowerPoint add-in development.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/how-to-create-powerpoint-add-in-in-cnet.html</link><author>noreply@blogger.com (C# Mentor)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpJnBrwOVrol2WEvMcJsTw_kXtN1IEzhpoQsv2qyx7Am3FT-LmDJy-rV_10DKBiezoLMzwI4x9MS2N5w-W_m7HLuLDegYen-76DuKbPYKDinZfBP7Xq02fSY7G8ZgxvmCu6K323lXHUZpl/s72-c?imgmax=800" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-7268245323784896268</guid><pubDate>Tue, 19 May 2009 16:16:00 +0000</pubDate><atom:updated>2009-05-19T09:54:07.172-07:00</atom:updated><title>Threading: Modal Progress Dialog and BackgroundWorker Thread in C#.Net</title><description>&lt;p&gt; &lt;/p&gt;  &lt;p&gt;While working with threads, one should be careful about UI Elements. Specially when we are working with BackgroundWorker thread. Here is an example which shows how to show a modal dialog from thread for displaying progress.&lt;/p&gt;  &lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px;&quot;&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; partial &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt; Form1 : Form&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; Form1()&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;            InitializeComponent();&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        BackgroundWorker worker;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        Form2 frm;&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; button1_Click(&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            frm = &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt; Form2();&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            worker = &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt; BackgroundWorker();&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            worker.WorkerReportsProgress = &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            worker.DoWork += &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt; DoWorkEventHandler(worker_DoWork);&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            worker.RunWorkerCompleted += &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt; RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            worker.ProgressChanged += &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;new&lt;/span&gt; ProgressChangedEventHandler(worker_ProgressChanged);&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            worker.RunWorkerAsync();     &lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            frm.ShowDialog();&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;      &lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; worker_ProgressChanged(&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt; sender, ProgressChangedEventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            frm.ProgressValue = e.ProgressPercentage;&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; worker_RunWorkerCompleted(&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt; sender, RunWorkerCompletedEventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            frm.Close();&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;            MessageBox.Show(&quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;Done&lt;/span&gt;&quot;);&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; worker_DoWork(&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt; sender, DoWorkEventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            CountTheTime();      &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;   &lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; CountTheTime()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; initialValue = 100;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; count = 0; count &amp;lt; initialValue; count = count + 2)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                Thread.Sleep(1000);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                worker.ReportProgress(count);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;In this example, I have simply created two windows forms. The first form [&lt;em&gt;Form1&lt;/em&gt;] has one button [&lt;em&gt;button1&lt;/em&gt;]. button1 will show create a &lt;strong&gt;BackgroundWorker&lt;/strong&gt; thread and launch it asynchronously. It uses method &lt;strong&gt;RunWorkerAsync&lt;/strong&gt; of &lt;strong&gt;BackgroundWorker&lt;/strong&gt; thread instance for this purpose&lt;br /&gt;&lt;p&gt;&lt;strong&gt;BackgroundWorker&lt;/strong&gt; has three main events&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;DoWork&lt;/strong&gt; - will be fired when we launch the thread.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;RunWorkerCompleted&lt;/strong&gt; - will fire when thread completes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;strong&gt;ProgressChanged&lt;/strong&gt; - will fire when thread reports progress&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;and important property&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;WorkerReportsProgress&lt;/strong&gt; – should be set to &lt;em&gt;True&lt;/em&gt; to enable progress reporting from a thread.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;related method&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;ReportProgress&lt;/strong&gt;() – Reports progress back to the calling thread.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; &lt;/p&gt;In aforementioned code, When we fire &lt;strong&gt;DoWork&lt;/strong&gt; event by calling &lt;strong&gt;RunWorkerAsync&lt;/strong&gt; method on worker thread. Eventhandler for this event will call the method &lt;em&gt;CountTheTime&lt;/em&gt;() on the form.&lt;br /&gt;&lt;p&gt;&lt;em&gt;CountTheTime&lt;/em&gt;() method intentionally put delay of 1 second. Here you can implement your time consuming code. We call &lt;strong&gt;ReportProgress&lt;/strong&gt;() method on the thread to pass progress from this background thread to the main UI thread which holds our progress bar. This method will fire &lt;strong&gt;ProgressChanged&lt;/strong&gt; Event&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px;&quot;&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;  &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; partial &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt; Form2 : Form&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; Form2()&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            InitializeComponent();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; ProgressValue&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;get&lt;/span&gt; { &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;return&lt;/span&gt; progressBar1.Value ; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;set&lt;/span&gt; { progressBar1.Value  = &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;value&lt;/span&gt;; }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;Then &lt;strong&gt;ProgressChanged&lt;/strong&gt; eventhandler, &lt;em&gt;worker_ProgressChanged&lt;/em&gt; updates the progressbar on Form2 with the help of &lt;em&gt;ProgressValue&lt;/em&gt; property.&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;br /&gt;&lt;/strong&gt;Simple example of modal Progressbar with &lt;strong&gt;BackgroundWorker&lt;/strong&gt; thread.&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/threading-modal-progress-dialog-and.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>7</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-1175033351828259655</guid><pubDate>Mon, 18 May 2009 16:57:00 +0000</pubDate><atom:updated>2009-05-18T10:04:52.758-07:00</atom:updated><title>Debugging: The breakpoint will not currently be hit. No symbols have been loaded for this document.</title><description>&lt;p&gt;&lt;br /&gt;This error suggest that you don’t have the latest version of the code matching with the executable(.Dll/.exe) for the debug session.&lt;/p&gt;      &lt;p&gt;&lt;strong&gt;Case 1: If you are attaching process to its excutable on different path&lt;/strong&gt;            &lt;br /&gt;&lt;/p&gt;&lt;p&gt;               1. First build you application in debug mode.&lt;br /&gt;                (Say E:\app\debug)&lt;/p&gt;    &lt;p&gt;                2. Take backup of deployed application’s executable.&lt;br /&gt;                  (Say C:\Program files\app\app.exe to C:\Program files\app\app123.exe).&lt;/p&gt;    &lt;p&gt;               3. Copy that executable from debug path in step 1 to&lt;br /&gt;                 the attachable application’s path in step 2&lt;br /&gt;                (Say E:\app\debug\app.exe to C:\Program files\app\app.exe)&lt;/p&gt;  &lt;p&gt;              4. Copy the dependent Dlls, if needed.&lt;/p&gt;  &lt;p&gt;And start your debugging by &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Running that external application. &lt;/li&gt;    &lt;li&gt;Then attaching your project to this application from Debug menu. &lt;/li&gt; &lt;/ul&gt;    &lt;p&gt; &lt;strong&gt;Case 2: In case your executable is in GAC&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;                1. First build you application in debug mode.&lt;br /&gt;                 (Say E:\app\debug)&lt;/p&gt;    &lt;p&gt;                2. Put it on some path&lt;br /&gt;                 (Say E:\GacDlls)&lt;/p&gt;  &lt;p&gt;               3. Add this excutable to &lt;strong&gt;GAC&lt;/strong&gt;. &lt;/p&gt;  &lt;p&gt;and happy debugging.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Case very common:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you are not holding any of the case or above solutions are of no use then try following&lt;/p&gt;    &lt;p&gt;           1. Look all modules are loaded for the current debugging session.&lt;br /&gt;             For this go to &lt;/p&gt;  &lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 15px; width: 351px; height: 19px;&quot;&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 40%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;   debug -&gt; Modules&lt;/pre&gt;&lt;/pre&gt;See all your modules are loaded. If any of the entries shows ‘&lt;span style=&quot;font-weight: bold;&quot;&gt;cannot find or open PDB file&lt;/span&gt;’ right-click that module and say &lt;span style=&quot;font-weight: bold;&quot;&gt;Load Symbols&lt;/span&gt; to browse for modules .&lt;strong&gt;PDB&lt;/strong&gt; File.&lt;br /&gt;&lt;p&gt;if you can’t find &lt;strong&gt;Modules&lt;/strong&gt; under Debug menu. Go to&lt;br /&gt;&lt;/p&gt;&lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 15px; width: 346px; height: 17px;&quot;&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 40%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;Tools -&gt; Customize&lt;/pre&gt;&lt;/pre&gt;Find &lt;strong&gt;Debug&lt;/strong&gt; item in &lt;strong&gt;Commands&lt;/strong&gt; Tab on left list choose corresponding &lt;strong&gt;Modules&lt;/strong&gt; item from right list and drag it to &lt;strong&gt;Debug menu&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;          2. Try to shutdown both IDE and external application(if any).&lt;br /&gt;             Reopen them, and try debugging.&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/debugging-breakpoint-will-not-currently.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-3540192099035370953</guid><pubDate>Tue, 12 May 2009 05:28:00 +0000</pubDate><atom:updated>2009-05-12T19:39:26.945-07:00</atom:updated><title>Scrolling in Multiline TextBox</title><description>In windows forms, We can have feature of scrolling for &lt;strong&gt;Multiline TextBox&lt;/strong&gt;.    &lt;br /&gt;&lt;p&gt;We can find text position to scroll up to. One can also scroll to the end of text box by setting the &lt;em&gt;&lt;strong&gt;SelectionStart&lt;/strong&gt;&lt;/em&gt; property appropriately.&lt;/p&gt;  &lt;p&gt;Following example shows, how to scroll to a specific word in the document. Actually you can use this function for providing search functionality for TextBox. &lt;/p&gt;  &lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 40px;&quot;&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; partial &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;class&lt;/span&gt; Form1 : Form&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;    {&lt;br /&gt;&lt;/pre&gt;&lt;pre   style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;font-family:consolas,&#39;Courier New&#39;,courier,monospace;font-size:12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;public&lt;/span&gt; Form1()&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%;&quot;&gt;            InitializeComponent();&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%;&quot;&gt;&lt;/pre&gt;&lt;pre face=&quot;consolas,&#39;Courier New&#39;,courier,monospace&quot; size=&quot;12px&quot; style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; ind = 0;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;int&lt;/span&gt; be = 0;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; button1_Click(&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            be = textBox1.Text.ToLower().IndexOf(&quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;as&lt;/span&gt;&quot;, ind + 1);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;if&lt;/span&gt; (be &amp;gt;= 0)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                textBox1.SelectionStart = be;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                textBox1.ScrollToCaret();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                textBox1.Select(be, 2);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                textBox1.Focus();&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;                ind = textBox1.Text.ToLower().IndexOf(&quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;as&lt;/span&gt;&quot;, be);&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;void&lt;/span&gt; Form1_Load(&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        {&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;            textBox1.Text = &quot;&lt;span style=&quot;color: rgb(139, 0, 0);&quot;&gt;In 1924, Einstein received a description of a statistical model from Indian physicist Satyendra Nath Bose, based on a counting method that assumed that light could be understood as a gas of indistinguishable particles. Bose&#39;s statistics applied to some atoms as well as to the proposed light particles, and Einstein submitted his translation of Bose&#39;s paper to the Zeitschrift für Physik. Einstein also published his own articles describing the model and its implications, among them the Bose-Einstein condensate phenomenon that should appear at very low temperatures . It was not until 1995 that the first such condensate was produced experimentally by Eric Allin Cornell and Carl Wieman using ultra-cooling equipment built at the NIST-JILA laboratory at the University of Colorado at Boulder. Bose-Einstein statistics are now used to describe the behaviors of any assembly of \&quot;bosons\&quot;. Einstein&#39;s sketches for this project may be seen in the Einstein Archive in the library of the Leiden University.&lt;/span&gt;&quot;;&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(255, 255, 255); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;&lt;/pre&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;    }&lt;/pre&gt;&lt;/pre&gt;To scroll to the end of the text box use &lt;br /&gt;&lt;pre style=&quot;border: 1px solid rgb(206, 206, 206); padding: 5px; overflow: auto; background-color: rgb(251, 251, 251); min-height: 20px;&quot;&gt;&lt;pre style=&quot;margin: 0em; background-color: rgb(251, 251, 251); width: 100%; font-family: consolas,&#39;Courier New&#39;,courier,monospace; font-size: 12px;&quot;&gt;textBox1.SelectionStart = textBox1.Text.Length&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Conclusion: &lt;/strong&gt;&lt;br /&gt;This is very simple code for searching text in TextBox and Scrolling.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Blogger Labels: &lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/Multiline&quot; rel=&quot;Tag&quot;&gt;Multiline&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/TextBox&quot; rel=&quot;Tag&quot;&gt;TextBox&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/text&quot; rel=&quot;Tag&quot;&gt;text&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/scroll&quot; rel=&quot;Tag&quot;&gt;scroll&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/SelectionStart&quot; rel=&quot;Tag&quot;&gt;SelectionStart&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/example&quot; rel=&quot;Tag&quot;&gt;example&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/word&quot; rel=&quot;Tag&quot;&gt;word&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/Form&quot; rel=&quot;Tag&quot;&gt;Form&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/InitializeComponent&quot; rel=&quot;Tag&quot;&gt;InitializeComponent&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/sender&quot; rel=&quot;Tag&quot;&gt;sender&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/EventArgs&quot; rel=&quot;Tag&quot;&gt;EventArgs&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/ToLower&quot; rel=&quot;Tag&quot;&gt;ToLower&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/IndexOf&quot; rel=&quot;Tag&quot;&gt;IndexOf&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/ScrollToCaret&quot; rel=&quot;Tag&quot;&gt;ScrollToCaret&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/Select&quot; rel=&quot;Tag&quot;&gt;Select&lt;/a&gt;,&lt;a href=&quot;http://csharpmentor.blogspot.com/search/label/Focus&quot; rel=&quot;Tag&quot;&gt;Focus&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/scrolling-in-multiline-textbox.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-4335690562395050345</guid><pubDate>Sat, 02 May 2009 12:21:00 +0000</pubDate><atom:updated>2009-05-02T18:52:46.728-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">Parsing</category><title>Parse integers safely</title><description>&lt;p&gt;Most of the times when we write code there is a need of data-type conversion. We may need to convert string into boolean, string into integers etc. Using Convert class to do these type of conversion is commonplace. But this is an error-prone practice as it may generate exception if the input is not convertible to the target type.&lt;/p&gt;  &lt;p&gt;So one can use the strategy explained below for converting string to integer-&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;private void testConversion()      &lt;br /&gt;{&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string tempString = &amp;quot;10&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int safeInt = 0;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; int defaultValue = 1000;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; safeInt = int.TryParse(inputValue, out safeInt ) ?&amp;#160; safeInt : defaultValue ;&lt;/p&gt;    &lt;p&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Here almost all built-in types have &lt;strong&gt;TryParse&lt;/strong&gt; static function which can be used for safe type parsing. In this example, &lt;strong&gt;int.TryParse&lt;/strong&gt; parses string into integer and save that converted value in &lt;em&gt;&lt;strong&gt;out&lt;/strong&gt; &lt;/em&gt;variable and will return a &lt;em&gt;&lt;strong&gt;true&lt;/strong&gt; &lt;/em&gt;value. If the string is not convertible it will return a &lt;em&gt;&lt;strong&gt;false&lt;/strong&gt; &lt;/em&gt;value. In case of &lt;em&gt;&lt;strong&gt;false&lt;/strong&gt;&lt;/em&gt; value, we can assign a default value to our final variable.&lt;/p&gt;  &lt;p&gt;Similar strategy can be employed for other data-type conversions, try it or find me here to help. Cheers!&lt;/p&gt;  &lt;p&gt;Hope this will make your code more safer.&lt;/p&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/parse-integers-safely.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-2644850265450837463</guid><pubDate>Sat, 02 May 2009 07:26:00 +0000</pubDate><atom:updated>2011-05-22T10:44:11.063-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Attributes</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">XML</category><title>Safely retrive attribute from XML Node in a Document</title><description>In XML processing, we commonly encounter a situation where we require to get the attribute value from a given XML Node. But most of the time it happens that the node may not contain the attribute itself. So if we try to get value of the attribute, runtime will definitely throw the exception. And exceptions are evils for the perfomance of any application.&lt;br /&gt;&lt;br /&gt;In such scenario, first we need to check for the existence of the attribute in the XML Node. Here &lt;span style=&quot;font-weight: bold;&quot;&gt;XMLElement&lt;/span&gt; class comes for the rescue. &lt;span style=&quot;font-weight: bold;&quot;&gt;XMLElement&lt;/span&gt; has a static method &lt;span style=&quot;font-weight: bold;&quot;&gt;HasAttribute&lt;/span&gt; which will serve the purpose of checking existence of the attribute in the given XML Node.&lt;br /&gt;&lt;br /&gt;Here is the sample which show how to get the attribute value safely&lt;br /&gt;&lt;br /&gt;  &lt;blockquote&gt; private string GetAttributeValue(XmlNode xNode, string attributeToFind)&lt;br /&gt;   {&lt;br /&gt;       string returnValue = string.Empty;&lt;br /&gt;       XmlElement ele = xNode as XmlElement;&lt;br /&gt;      &lt;br /&gt;       if (ele.HasAttribute(attributeToFind))&lt;br /&gt;           returnValue= ele.GetAttribute(attributeToFind);&lt;br /&gt;&lt;br /&gt;       return returnValue;&lt;br /&gt;   }&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Hope this will help.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2009/05/safely-retrive-attribute-from-xml-node.html</link><author>noreply@blogger.com (C# Mentor)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9210426025253654417.post-6482852575549373676</guid><pubDate>Wed, 21 Feb 2007 09:07:00 +0000</pubDate><atom:updated>2009-05-30T19:57:57.273-07:00</atom:updated><title>I welcome all programmer friends !</title><description>I welcome everybody from developer community. I will be writing my experiences,experiments with c#. This may also have feeds form several expert sites, which will helpful to all my friends who are in programming and especially in c#.Net. If you any kind of question regarding programming (not just C#), please feel free to post comment in corresponding section. I value suggestions, and expecting from you.&lt;br /&gt;Have great time!&lt;br /&gt;&lt;br /&gt;&lt;script&gt;&lt;br /&gt; britepic_id=&quot;1153903&quot;;&lt;br /&gt; britepic_src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAsj_vYmSiO_BBKOKVADJLynWcHnKNiVMTndMTry7ccGc0aygIHbD5JWjyStxHsvczz57Vty1WrRVY_gf1nS2_Sj1aXcQuBfT7FmIfpvfkVZzXSt6UdUhFTBM1iOf1gekGfCwpSMp7yFjR/s1600-h/Step%201%5B14%5D.jpg&quot;;&lt;br /&gt; britepic_keywords=&quot;C%23,%20powerpoint,%20shared,%20add%20in,%20vsto&quot;;&lt;br /&gt; britepic_show_ads=1;&lt;br /&gt; britepic_show_menu=1;&lt;br /&gt; britepic_href=&quot;http%3A//&quot;;&lt;br /&gt; britepic_caption=&quot;Select Project type - shared add-in&quot;;&lt;br /&gt; britepic_width=300;&lt;br /&gt; britepic_height=300;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script src=&quot;http://www.britepic.com/britepic.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;&lt;noscript&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAsj_vYmSiO_BBKOKVADJLynWcHnKNiVMTndMTry7ccGc0aygIHbD5JWjyStxHsvczz57Vty1WrRVY_gf1nS2_Sj1aXcQuBfT7FmIfpvfkVZzXSt6UdUhFTBM1iOf1gekGfCwpSMp7yFjR/s1600-h/Step%201%5B14%5D.jpg&quot; width=&quot;300&quot; height=&quot;300&quot;&gt;&lt;/noscript&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;form action=&#39;http://www.r-mail.org/&#39; method=&#39;post&#39;&gt;&lt;div&gt;
&lt;input type=&#39;hidden&#39; name=&#39;rss&#39; value=&#39;http://feeds.feedburner.com/TheRSSBlog&#39; /&gt;
Email:&lt;input type=&#39;text&#39; name=&#39;mailto&#39; value=&#39;&#39; /&gt;&lt;/div&gt;
&lt;div&gt;&lt;input type=&#39;submit&#39; value=&#39;Subscribe&#39; /&gt;&lt;/div&gt;
&lt;div style=&#39;font-size:xx-small;&#39;&gt;
&lt;a href=&#39;http://www.r-mail.org/&#39;&gt;R-mail powered&lt;/a&gt;&lt;/div&gt;&lt;/form&gt;&lt;/div&gt;</description><link>http://csharpmentor.blogspot.com/2007/02/everybody-from-programming-world-is.html</link><author>noreply@blogger.com (C# Mentor)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAsj_vYmSiO_BBKOKVADJLynWcHnKNiVMTndMTry7ccGc0aygIHbD5JWjyStxHsvczz57Vty1WrRVY_gf1nS2_Sj1aXcQuBfT7FmIfpvfkVZzXSt6UdUhFTBM1iOf1gekGfCwpSMp7yFjR/s72-c-h/Step%201%5B14%5D.jpg" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>