<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technology Bits and Bytes &#187; .Net</title>
	<atom:link href="http://blogs.circlesource.com/category/dotnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.circlesource.com</link>
	<description>CircleSource Technical Talent ShowCase</description>
	<lastBuildDate>Thu, 10 Dec 2009 20:01:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dynamically Changing MasterPage</title>
		<link>http://blogs.circlesource.com/2009/04/27/dynamically-changing-masterpage/</link>
		<comments>http://blogs.circlesource.com/2009/04/27/dynamically-changing-masterpage/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 10:49:21 +0000</pubDate>
		<dc:creator>murulidhara.k</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Baseclass]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Inheritence]]></category>
		<category><![CDATA[MasterPage]]></category>
		<category><![CDATA[OnPreinit]]></category>
		<category><![CDATA[Overriding]]></category>
		<category><![CDATA[Page Class]]></category>
		<category><![CDATA[Sessions]]></category>
		<category><![CDATA[Themes]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=453</guid>
		<description><![CDATA[Changing MasterPage Dynamically
In real-time we may come across scenario where depending on the particular group of users we need to show different layout, colors, themes, functionalities and so on. To achieve this there are various ways, maintain the settings for each user in table , maintain the cookies and so on. 
 In .net the best [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.25in; line-height: 150%;"><strong><span style="font-size: small;"><span style="font-family: Calibri;">Changing MasterPage Dynamically</span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.25in; line-height: 150%;"><span style="font-size: small;"><span style="font-family: Calibri;">In real-time we may come across scenario where depending on the particular group of users we need to show different layout, colors, themes, functionalities and so on. To achieve this there are various ways, maintain the settings for each user in table , maintain the cookies and so on. </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt; text-indent: 0.25in; line-height: 150%;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="mso-spacerun: yes;"> </span>In .net the best way to achieve this is to change master page dynamically where the master pages will have different layout , different look and feel for different users.<span style="mso-spacerun: yes;">  </span>This we can achieve by following below mentioned steps.</span></span></p>
<p class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; line-height: 150%; mso-list: l1 level1 lfo1;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">1.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">All the WebPages will be inherited form System.UI.Web.Page base class</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; line-height: 150%; mso-list: l1 level1 lfo1;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">2.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">In page directive we<span style="mso-spacerun: yes;">  </span>have a property to set masterpage file</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; line-height: 150%; mso-list: l1 level1 lfo1;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">3.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">Once we attach any master page to any child, first all the controls of the master page are instantiated, then child page controls are instantiated</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; line-height: 150%; mso-list: l1 level1 lfo1;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">4.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">If we want to apply master page in code behind file ,the page’s master page property needs to be applied in Onpreinit method only.</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-indent: -0.25in; line-height: 150%; mso-list: l1 level1 lfo1;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">5.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">After instantiating controls, child page load will be called first, then the master page will be loaded.</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; line-height: 150%;"><span style="font-size: small;"><span style="font-family: Calibri;">To change master page dynamically we need to follow the below mentioned process/method</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.75in; text-indent: -0.25in; line-height: 150%; mso-list: l0 level1 lfo2; mso-add-space: auto;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">1.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">Create one separate class file as public, which will inherits System.UI.Web.Page base class</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.75in; text-indent: -0.25in; line-height: 150%; mso-list: l0 level1 lfo2; mso-add-space: auto;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">2.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">Override the Page base class method onPreinit(), in this method set the master page property of the page, give the name of the master page file which you want to apply</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.75in; text-indent: -0.25in; line-height: 150%; mso-list: l0 level1 lfo2; mso-add-space: auto;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">3.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">At the end of the onPreinit() method call the base class onpreinit method</span></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.75in; text-indent: -0.25in; line-height: 150%; mso-list: l0 level1 lfo2; mso-add-space: auto;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">4.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">Inherit the newly created class in all of your web pages.</span></span></p>
<p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.75in; text-indent: -0.25in; line-height: 150%; mso-list: l0 level1 lfo2; mso-add-space: auto;"><span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-size: small; font-family: Calibri;">5.</span><span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;">To provide the custom master page, we may use cookies, sessions or the values stored from database, it depends on how we want to manage the customization.</span></span></p>
<p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.75in; text-indent: -0.25in; line-height: 150%; mso-list: l0 level1 lfo2; mso-add-space: auto;"> </p>
<div></div>
<p><span style="font-size: small;"><span style="font-family: Calibri;"></p>
<div id="attachment_454" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-454" src="http://blogs.circlesource.com/wp-content/uploads/2009/04/classdiagram-300x273.jpg" alt="Illustration" width="300" height="273" /><p class="wp-caption-text">Illustration</p></div>
<p> </p>
<p> </p>
<p></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/04/27/dynamically-changing-masterpage/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Merging Image and text in a single gridview cell</title>
		<link>http://blogs.circlesource.com/2009/04/17/merging-image-and-text-in-a-single-gridview-cell/</link>
		<comments>http://blogs.circlesource.com/2009/04/17/merging-image-and-text-in-a-single-gridview-cell/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 14:46:14 +0000</pubDate>
		<dc:creator>Asif Mohammad</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Add Image to DataGridViewTextBoxCell]]></category>
		<category><![CDATA[Add image to DataGridViewTextBoxColumn]]></category>
		<category><![CDATA[Add text to DataGridViewImageColumn]]></category>
		<category><![CDATA[Merging Image and text in a single gridview cell]]></category>
		<category><![CDATA[Merging two cells of gridview]]></category>
		<category><![CDATA[paint custom text / Image in gridview cell.]]></category>
		<category><![CDATA[Showing Image with text in datagridview]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=385</guid>
		<description><![CDATA[Neither you can add image in DataGridViewTextBoxColumn nor you can add text in DataGridViewImageColumn so merging text and image in the same cell in datagridview is bit tricky. To achieve this you can create your own control inheriting from “DataGridViewTextBoxColumn” and overriding paint method. Or you can track the grid view’s paint event and write [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: 12pt; line-height: 115%;">Neither you can add image </span><span style="font-size: 12pt; line-height: 115%;">in DataGridViewTextBoxColumn </span><span style="font-size: 12pt; line-height: 115%;">nor you can add text in DataGridViewImageColumn so merging text and image in the same cell in datagridview is bit tricky.</span><span style="font-size: 12pt; line-height: 115%;"> To achieve this you can create your own control inheriting from “</span><span style="font-size: 12pt; line-height: 115%;">DataGridViewTextBoxColumn” and overriding paint method. Or you can track the grid view’s paint event and write the below functionality</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: blue;">Private</span><span style="font-size: 10pt;"> <span style="color: blue;">Sub</span> GridView1_Paint(<span style="color: blue;">ByVal</span> sender <span style="color: blue;">As</span> System.Object, <span style="color: blue;">ByVal</span> e <span style="color: blue;">As</span> System.Windows.Forms.PaintEventArgs) <span style="color: blue;">Handles</span> GridView1.Paint</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: blue;">Dim</span><span style="font-size: 10pt;"> count <span style="color: blue;">As</span> <span style="color: blue;">Integer</span> <span> </span>= 0<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: blue;">Dim</span><span style="font-size: 10pt;"> xCordinate <span style="color: blue;">As</span> <span style="color: blue;">Integer</span> = _</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;">GridView1<span>.GetColumnDisplayRectangle(</span>GridView1<span>.Columns(“</span>column1”<span>).Index, <span style="color: blue;">True</span>).X + 11</span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: #c00000;">1.</span><span style="font-size: 10pt; color: blue;"> For</span><span style="font-size: 10pt;"> count = GridView1.FirstDisplayedScrollingRowIndex <span style="color: blue;">To</span> (GridView1.FirstDisplayedScrollingRowIndex + 7)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: #c00000;">2.</span><span style="font-size: 10pt;"><span> </span><span style="color: blue;">If</span> count &lt; GridView1.Rows.Count <span style="color: blue;">Then</span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: #c00000;">3.</span><span style="font-size: 10pt;"><span> </span><span style="color: blue;">Dim</span> rct <span style="color: blue;">As</span> Rectangle = GridView1.GetRowDisplayRectangle(count, <span style="color: blue;">True</span>)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: #c00000;">4.</span><span style="font-size: 10pt; color: blue;"> <span>Dim</span></span><span style="font-size: 10pt;"> rct2 <span style="color: blue;">As</span> <span style="color: blue;">New</span> Rectangle(xCordinate, rct.Y, 26, 25)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; color: #c00000;">5.</span><span style="font-size: 10pt;"> e.Graphics.DrawImageUnscaledAndClipped(<span style="color: blue;">My</span>.Resources.Image1, rct2)</span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"><span> </span><span style="color: blue;">End</span> <span style="color: blue;">If</span></span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt;"><span> </span><span style="color: blue;">Next</span></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%;"><span> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span></span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%; color: blue;"> </span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-size: 12pt; line-height: 115%; color: black;">Here are the details of steps mentioned above</span></span></strong></p>
<p class="MsoNormal"><strong><span style="font-size: 12pt; line-height: 115%; color: black;">1.<span> </span></span></strong><span style="font-size: 12pt; line-height: 115%; color: black;">Looping thorough the rows which comes under visible area<strong>. </strong>Here in the sample code we have 8 rows visible at a time rest are coming under horizontal scroll. So we loop through only those rows starting from “</span><span>FirstDisplayedScrollingRowIndex</span><span style="font-size: 12pt; line-height: 115%; color: black;"> “ and paint cell with an added image.</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%; color: black;">3.<span> </span>Get the rectangle dimension of each row. This is to set the y coordinate of each image we are going to paint manually</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%; color: black;">4. Get the rectangle dimension of the </span><span style="font-size: 12pt; line-height: 115%;">area </span><span style="font-size: 12pt; line-height: 115%; color: black;">under which we want to paint the image.</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%; color: black;"><span> </span>Here the left coordinate of </span><span style="font-size: 12pt; line-height: 115%;">rct2 </span><span style="font-size: 12pt; line-height: 115%; color: black;">is set by taking the X coordinate of the </span><span style="font-size: 12pt; line-height: 115%;">DataGridViewTextBoxColumn under which we are going to paint the image and adding 11 pixels to accommodate the text.</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%;">Y coordinate is the Y coordinate of each row</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%;">Width and height of rct2 is the dimension of the image we are going to paint</span></p>
<p class="MsoNormal"><span style="font-size: 12pt; line-height: 115%;">5. “DrawImageUnscaledAndClipped” draws the image without scaling it and clipped by the rectangle passed as a second parameter</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/04/17/merging-image-and-text-in-a-single-gridview-cell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title></title>
		<link>http://blogs.circlesource.com/2009/04/02/348/</link>
		<comments>http://blogs.circlesource.com/2009/04/02/348/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 11:19:47 +0000</pubDate>
		<dc:creator>nikhil.kumar</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[TIMEDIFF]]></category>
		<category><![CDATA[TIMESTAMPDIFF]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=348</guid>
		<description><![CDATA[Dealing with MySQL TIMEDIFF() for hours greater than 838
Let&#8217;s have a look at the TIMEDIFF() function in MySQL:
TIMEDIFF(expr1,expr2) - TIMEDIFF() returns expr1 &#8211; expr2 expressed as a time value. expr1 and expr2 are time or date-and-time expressions, but both must be of the same type.
It seems that when TimeDiff is performed on 2 dates that [...]]]></description>
			<content:encoded><![CDATA[<div style="font:12px;"><strong>Dealing with MySQL TIMEDIFF() for hours greater than 838</strong></p>
<p>Let&#8217;s have a look at the TIMEDIFF() function in MySQL:</p>
<p><code><strong>TIMEDIFF(<em>expr1</em>,<em>expr2</em>) -</strong></code> <code>TIMEDIFF()</code> returns <code><em>expr1</em></code> &#8211; <code><em>expr2</em></code> expressed as a time value. <code><em>expr1</em></code> and <code><em>expr2</em></code> are time or date-and-time expressions, but both must be of the same type.</p>
<p>It seems that when TimeDiff is performed on 2 dates that exceed 36 days then a warning is thrown, and the resulting value is always capped to 838.</p>
<p><strong>For example:</strong></p>
<p>select time_format(timediff(&#8216;2009-02-05 00:00:00&#8242;,&#8217;2009-01-01 00:00:00&#8242;),&#8217;%H&#8217;) as TimeDifference</p>
<p>If you execute the above query MySQL will return 838 instead of returning 840 (35 X 24 = 840).</p>
<p>The reason is precisely because TIME type in MySQL has an upper bound of 838:59:59. TIME values may range from &#8216;-838:59:59′ to &#8216;838:59:59′.</p>
<p><code>By using TIMESTAMPDIFF() function you can get around with this problem.</code></p>
<p>Let&#8217;s have a look at the <code>TIMESTAMPDIFF</code>() function in MySQL:</p>
<p><code><strong>TIMESTAMPDIFF(<em>unit</em>,<em>datetime_expr1</em>,<em>datetime_expr2</em>)</strong></code><strong> &#8211; </strong>Returns <code><em>datetime_expr2</em></code><code> - <em>datetime_expr1</em></code>, where <code><em>datetime_expr1</em></code> and <code><em>datetime_expr2</em></code> are date or datetime expressions. One expression may be a date and the other a datetime; a date value is treated as a datetime having the time part <code>'00:00:00'</code> where necessary. The unit for the result (an integer) is given by the <code><em>unit</em></code> argument. The legal values for <code><em>unit</em></code> are <code>FRAC_SECOND</code> (microseconds), <code>SECOND</code>, <code>MINUTE</code>, <code>HOUR</code>, <code>DAY</code>, <code>WEEK</code>, <code>MONTH</code>, <code>QUARTER</code>, or <code>YEAR</code>.</p>
<pre>It is bit confusing timediff and timestampdiff expects the times in opposite order.</pre>
<p>Now let&#8217;s try timestampdiff() with same dates</p>
<p>select timestampdiff(hour,&#8217;2009-01-01 00:00:00&#8242;,&#8217;2009-02-05 00:00:00&#8242;) as TimeDifference</p>
<p>If you execute the above query MySQL will return 840. Even if the difference is more than 840 it will not throw any exceptions or any warning. Hence we can use TIMESTAMPDIFF() function where the difference is more than 838 and can get the output in any of <code>FRAC_SECOND</code> (microseconds), <code>SECOND</code>, <code>MINUTE</code>, <code>HOUR</code>, <code>DAY</code>, <code>WEEK</code>, <code>MONTH</code>, <code>QUARTER</code>, or <code>YEAR</code>.</p>
<p>There you have it &#8230; I hope you enjoyed this article. Please leave comments / suggestions / questions if you have.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/04/02/348/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Connection string (ADO.NET)</title>
		<link>http://blogs.circlesource.com/2009/02/22/building-connection-string/</link>
		<comments>http://blogs.circlesource.com/2009/02/22/building-connection-string/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 07:18:21 +0000</pubDate>
		<dc:creator>MANOJ MATHE</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Building Connection string for ADO.NET]]></category>
		<category><![CDATA[Building Connection string for any database]]></category>
		<category><![CDATA[Building Connection string for database interaction]]></category>
		<category><![CDATA[Building Connection string in easy way]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=328</guid>
		<description><![CDATA[Building Connection string
Introduction:
        As we know we use to build the connection strings by copying the existing connection string and renaming the DatsourceName,UserName,Password like that but here we will be discussing about how to build the connection string without copy paste.
Approach:
There is a way to build the connection [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Building Connection string</strong></p>
<p><strong>Introduction:</strong></p>
<p>        As we know we use to build the connection strings by copying the existing connection string and renaming the DatsourceName,UserName,Password like that but here we will be discussing about how to build the connection string without copy paste.</p>
<p><strong>Approach:</strong></p>
<p>There is a way to build the connection string for any database which DotNet supports.<br />
<strong><br />
1.Open a notepad </strong></p>
<p><a rel="attachment wp-att-327" href="http://blogs.circlesource.com/2009/02/22/building-connection-string/bs1/"><img class="aligncenter size-full wp-image-327" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/bs1.bmp" alt="save Notepad as" /></a></p>
<p>And save it as somename.udl where udl (Universal Data Link) is the extension the udl files are used to build the connection string we can directly use the udl file to open the connection to the database</p>
<p><strong><br />
2. Then you can find the file with the following icon as shown below </strong></p>
<p><a rel="attachment wp-att-329" href="http://blogs.circlesource.com/2009/02/22/building-connection-string/bs2/"><img class="aligncenter size-full wp-image-329" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/bs2.bmp" alt="Icon" /></a></p>
<p><strong><br />
3. Now open this file by double click it will be as shown below </strong></p>
<p><a rel="attachment wp-att-330" href="http://blogs.circlesource.com/2009/02/22/building-connection-string/bs3/"><img class="aligncenter size-full wp-image-330" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/bs3.bmp" alt="Provider" /></a></p>
<p>Now select the provider what ever you like from the list and click next in my case I am selecting the Oledb SqlProvider and clicking next</p>
<p><strong>4.Then you can see the screen as below </strong></p>
<p><a rel="attachment wp-att-331" href="http://blogs.circlesource.com/2009/02/22/building-connection-string/bs4/"><img class="aligncenter size-full wp-image-331" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/bs4.bmp" alt="Details" /></a></p>
<p>then we need to provide the server name ,username if you are not using windows authentication and check the allow saving password option for saving the password in the file now select the database to which you need the connection and then click ok.</p>
<p><strong>Note: &#8211; You can find the database list if the details provided by you are valid </strong></p>
<p><strong>5. Now the connection string is ready </strong></p>
<p><strong> How to use this:</strong><br />
              1.You can directly use the udl file to open the connection and connect to the database but the limitation is it is supported<br />
                  by oledb Providers only.Sample code</p>
<p>                 <code>OleDbConnection connection = new OleDbConnection("File Name= D:\\connection.udl");<br />
                 OleDbCommand command = new OleDbCommand("select * from Cities",connection);<br />
                 OleDbDataReader reader;<br />
                 try<br />
                 {<br />
                     connection.Open();<br />
                     reader = command.ExecuteReader();<br />
                     while (reader.Read())<br />
                     {<br />
                            ListBox1.Items.Add(reader["Cities"].ToString());<br />
                            ListBox2.Items.Add(reader["Cities"].ToString());<br />
                      }<br />
                      ListBox1.DataBind();<br />
                      ListBox2.DataBind();<br />
                 }<br />
                catch (Exception error)<br />
                { }<br />
                finally<br />
                {<br />
                  connection.Close();<br />
                 }</code></p>
<p>              2. You can directly get the connection string from the file and we can use directly in our code<br />
              Open the file with notepad as shown below</p>
<p><a rel="attachment wp-att-332" href="http://blogs.circlesource.com/2009/02/22/building-connection-string/bs5/"><img class="aligncenter size-full wp-image-332" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/bs5.bmp" alt="Opening the file" /></a></p>
<p>                And there you can find your connection string like this</p>
<p>               [oledb]<br />
               ; Everything after this line is an OLE DB initstring<br />
               <strong><br />
                 Provider=SQLOLEDB.1;Password=mypassword;Persist Security Info=True;User ID=username;Initial<br />
                 Catalog=datbasename;Data Source=servername</strong></p>
<p><strong>Conclusion: -</strong></p>
<p><strong>By using this udl files we can build connection string for any type of database easily.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/02/22/building-connection-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dynamically creation of web controls and binding Validations Using ASP.NET</title>
		<link>http://blogs.circlesource.com/2009/02/05/dynamically-creation-of-web-controls-and-binding-with-validations/</link>
		<comments>http://blogs.circlesource.com/2009/02/05/dynamically-creation-of-web-controls-and-binding-with-validations/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 12:20:50 +0000</pubDate>
		<dc:creator>MANOJ MATHE</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[Dynamically creation of web controls and binding Validations]]></category>
		<category><![CDATA[Dynamically creation of web controls and binding Validations Using ASP.NET]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=229</guid>
		<description><![CDATA[CreatingDynamicControls_Source
Introduction:-
As we know we can bind the controls to our page (aspx) in 2 ways
1. Statically :- Binding the controls while Designing
2. Dynamically :- Binding the controls at runtime
Everyone know how to bind statically but there may be some cases where we need to bind the control dynamically .One of those cases is when our [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-236" href="http://blogs.circlesource.com/2009/02/05/dynamically-creation-of-web-controls-and-binding-with-validations/creatingdynamiccontrols2/">CreatingDynamicControls_Source</a><br />
<strong>Introduction:-</strong></p>
<p>As we know we can bind the controls to our page (aspx) in 2 ways<br />
1. Statically :- Binding the controls while Designing<br />
2. Dynamically :- Binding the controls at runtime</p>
<p>Everyone know how to bind statically but there may be some cases where we need to bind the control dynamically .One of those cases is when our controls are keep on changing like I have a registration site in which the control type may keep on changing then I may need to go for binding the controls dynamically .<br />
<strong><br />
Approach:</strong></p>
<p>For binding the controls I need the data what are the controls I want to bind and what is the id to be given and what are the properties to be provided etc.,</p>
<p>This can be provided by 2 ways </p>
<p><span id="more-229"></span></p>
<p>1. Using database (This is my approach)<br />
2. Using Xml file</p>
<p>I am creating one example (registration Page) where I am getting the data from the database as a table and based on this table I will be binding my controls to the page as we can see below</p>
<p><img class="aligncenter size-full wp-image-231" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/picture1.bmp" alt="picture1" width="577" height="219" /></p>
<p>My Controls Data from database</p>
<p><strong>ControlText : </strong>- Text to be Displayed</p>
<p><strong>ControlType :</strong>-</p>
<p>1 &#8211; TextBox Control<br />
2 &#8211; DropDown Control<br />
3 &#8211; DateTime Control<br />
4 &#8211; Buttom Control</p>
<p><strong>MaxLength:</strong>- Defining the maximum length for textbox</p>
<p><strong>Manditory :</strong>- Based On this we will be binding the required field validation</p>
<p><strong>HelpText :</strong>- This is used to bind as ToolTip for the control</p>
<p><strong>Source :</strong>- Use for binding data source for dropdown controls</p>
<p><img class="aligncenter size-full wp-image-232" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/picture2.bmp" alt="picture2" /></p>
<p>Page in which all the controls are generated dynamically</p>
<p><strong>Implementation:</strong></p>
<p>As we know all the server control are under System.Web.UI.WebControls namespace</p>
<p>I will be getting the tabel into a dataset for suppose the name is controlsDataSet</p>
<p><code>///<br />
/// Method usd to bind the controls<br />
///<br />
///<br />
private void BuldControls(DataSet controlsDataSet)<br />
{<br />
Table table = new Table();<br />
table.Style.Add("align", "center");</code></p>
<p>// Looping the dataset and get the values<br />
foreach (DataRow datarow in controlsDataSet.Tables[0].Rows)<br />
{<br />
int controlType =<br />
Convert.ToInt32(datarow["ControlType"].ToString());<br />
string controlText = datarow ["ControlText"].ToString();</p>
<p>TableRow newRow = new TableRow();<br />
TableCell textCell = new TableCell();</p>
<p>// Binding the text<br />
textCell.Text = controlText;<br />
newRow.Cells.Add(textCell);</p>
<p>TableCell valueCell = new TableCell();<br />
Control[] cntrlCollection=new Control[4];</p>
<p>// Checking the control Type<br />
switch(controlType)<br />
{<br />
// If TextBox<br />
case 1:<br />
cntrlCollection = this.BindTextBox(control);<br />
break;</p>
<p>// If DropDown<br />
case 2:<br />
cntrlCollection = this.BindDropDown(control);<br />
break;</p>
<p>// If DateTime<br />
case 3:<br />
cntrlCollection = this.BindDateTime(control);<br />
break;</p>
<p>// If Button<br />
case 4:<br />
cntrlCollection = this.BindButton(control);<br />
break;</p>
<p>}</p>
<p>// Adding th controls to the table cell<br />
foreach (Control cntrl in cntrlCollection)<br />
{<br />
if (cntrl != null)<br />
{<br />
valueCell.Controls.Add(cntrl);<br />
}<br />
}</p>
<p>newRow.Cells.Add(valueCell);<br />
table.Rows.Add(newRow);<br />
}</p>
<p>// Adding the table to the main panel<br />
this.pnlControls.Controls.Add(table);<br />
}</p>
<p>Creating controls dynamically is not a big matter but we have bind in such a way that when we are retriving it should not be a problem so we need to give the ids of the controls as below</p>
<p>///<br />
/// Method to bind the DropDown<br />
///<br />
///<br />
///<br />
private Control[] BindTextBox(DataRow datarow)<br />
{<br />
// Retriving the values from the datarow<br />
int controlId = Convert.ToInt32(datarow["Id"].ToString());<br />
int length = Convert.ToInt32(datarow["MaxLengh"].ToString());<br />
bool required =<br />
Convert.ToBoolean(datarow["Manditory"].ToString());<br />
string helpText = datarow["HelpText"].ToString();<br />
string controlText = datarow["ControlText"].ToString();</p>
<p>// Creating the controls array<br />
Control[] controls = new Control[4];</p>
<p>// creating the textbox<br />
TextBox textbox = new TextBox();<br />
textbox.ID = string.Concat(&#8220;txt&#8221;, controlId);<br />
textbox.ToolTip = helpText;</p>
<p>// Checking the length<br />
if (length != 0)<br />
{<br />
textbox.MaxLength = length;<br />
}</p>
<p>// Adding the textbox to the control array<br />
controls[0] = textbox;</p>
<p>// Checking id manditory<br />
if (required)<br />
{<br />
controls[1] = this.BindRequiredvalidator(controlId,<br />
textbox.ID, controlText);<br />
}<br />
return controls;<br />
}</p>
<p>Suppose I am bind for the name column the textbox id becomes like this<br />
“txt_1” and while saving also we can save accordingly.</p>
<p>So this is the way how to bind the controls and now coming to validation controls (I and using the controls provided my the VS).I am showing you a example where I am bind a validation control to textbox as shown below</p>
<p>private RequiredFieldValidator BindRequiredvalidator(int Id, string<br />
controlId, string controlText)<br />
{<br />
RequiredFieldValidator requiredFieldValidator = new<br />
RequiredFieldValidator();<br />
requiredFieldValidator.ID = string.Concat(&#8220;rfv&#8221;, Id);<br />
requiredFieldValidator.ControlToValidate = controlId;<br />
requiredFieldValidator.SetFocusOnError = true;<br />
requiredFieldValidator.ErrorMessage = string.Concat(&#8220;Enter &#8220;,<br />
controlText);<br />
return requiredFieldValidator;</p>
<p>}</p>
<p>For this method I will be passing the Id , ControlId (Like textbox control id) which need to be validated ,controlText used for error messaeges</p>
<p>And after doing all these we can see the paeg with validation controls like this</p>
<p><img class="aligncenter size-full wp-image-233" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/picture3.bmp" alt="picture3" /></p>
<p>With Validation controls</p>
<p><strong>Advantages over binding controls statically:</strong></p>
<p>1. Suppose we need to add 10 controls and we are using those statically but now I need to change my control type like a textbox to be changed to dropdown then I need to change all my code once again but this easier while binding controls dynamically.<br />
2. Can bind any validation to any control dynamically.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/02/05/dynamically-creation-of-web-controls-and-binding-with-validations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>UML: Usecase Diagrams and Class Diagrams</title>
		<link>http://blogs.circlesource.com/2009/02/02/uml-usecase-diagrams-and-class-diagrams/</link>
		<comments>http://blogs.circlesource.com/2009/02/02/uml-usecase-diagrams-and-class-diagrams/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 15:58:57 +0000</pubDate>
		<dc:creator>murulidhara.k</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=199</guid>
		<description><![CDATA[Uses Cases and Class Diagrams
The use cases and class diagrams are very useful in order to plan and designing any project. Before understanding use cases and diagrams we need to know regarding UML.
UML can be abbreviated as Unified Modeling Language, which is used in order to provide a common modeling for various
problems/projects which are platform [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><strong><span style="font-size:14.0pt;line-height:115%">Uses Cases and Class Diagrams</span></strong></p>
<p class="MsoNormal" style="text-indent:.5in">The use cases and class diagrams are very useful in order to plan and designing any project. Before understanding use cases and diagrams we need to know regarding UML.</p>
<p class="MsoNormal" style="text-indent:.5in">UML can be abbreviated as Unified Modeling Language, which is used in order to provide a common modeling for various<br />
problems/projects which are platform independent, technology independent and support purely object oriented programming languages.</p>
<p class="MsoNormal" style="text-indent:.5in">The use cases can be defined in simple word as scenario in which the given problem solution will be used and what are all the cases that may arise while using the project/solution.</p>
<p class="MsoNormal" style="text-indent:.5in">The use cases helps the system design and development easier by providing the necessary and mandatory cases that are the users of any project.  The use cases can be represented by using standard notations.  The following are the notations which are used in order derive the use cases most commonly.</p>
<p class="MsoNormal"><img class="aligncenter size-medium wp-image-218" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image001-300x123.jpg" alt="image001" width="300" height="123" /></p>
<p class="Section1">In order to understand the use cases in better way, let me explain an example, consider the video conference system as a problem/project, in order to implement this project first I need to gather the information from user/client properly once the required information is gathered by using any of the information gathering techniques, I can start on writing the use cases for video conference system.</p>
<p class="MsoNormal" style="text-indent:.5in">The use cases are formed or designed by considering the main functional requirements of the system not mapped one-to-one and it shows what behavior the actor can expect and not how the system will work to provide the service.</p>
<p class="MsoNormal">In order to write the use cases we need to know two things properly in use cases</p>
<p class="MsoNormal" style="margin-left:.75in;text-indent:-.25in">1.  Actor,the external agent who will make use of the system</p>
<p class="MsoNormal" style="margin-left:.75in;text-indent:-.25in">2. Service provided by the System</p>
<p class="MsoNormal" style="text-indent:.5in">In the video conference system the actors are the persons who will make use of the system by connecting to the system, and the services provided by the system are login authentication, video conferencing, video recording, text messaging.  These are all the main functional requirements which are identified in order to develop the video conferencing system.  The following are the different use cases those can be derived or drawn by considering the video conferencing system and the services provided by the system.</p>
<p class="MsoNormal" style="text-indent:.5in">The following are the example/illustrative use case diagrams with respect to web based video conferencing system, which is used for video conferencing over the internet.</p>
<div class="Section1">
<ul>
<li>
<div class="MsoNormal">Login Authentication</div>
</li>
<li>
<div class="MsoNormal">Video Conferencing</div>
</li>
<li>
<div class="MsoNormal">Chat: Text Messaging</div>
</li>
<li>
<div class="MsoNormal">Video Recording</div>
</li>
</ul>
</div>
<p> </p>
<p class="MsoNormal">  <img class="size-medium wp-image-205 alignnone" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image002-300x159.jpg" alt="image002" width="300" height="159" /></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> <img class="aligncenter size-medium wp-image-206" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image003-300x167.jpg" alt="image003" width="300" height="167" /></p>
<p class="MsoNormal"> </p>
<p><img class="aligncenter size-medium wp-image-210" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image0041-300x185.jpg" alt="image0041" width="300" height="185" /></p>
<p><img class="aligncenter size-medium wp-image-211" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image0052-300x258.jpg" alt="image0052" width="300" height="258" /><img class="aligncenter size-medium wp-image-213" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image006-300x123.jpg" alt="image006" width="300" height="123" /> </p>
<p class="MsoNormal">The use case diagrams does have extension, aggregation and interface concept those can be represented pictorially as above.</p>
<p><span style="font-size:11.0pt;line-height:115%;font-family:"><br />
</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><strong><span style="font-size:14.0pt;line-height:115%">Class Diagrams</span></strong></p>
<p class="MsoNormal">                The class diagrams are diagrams which are used in order to represent the classes used or to be used in any solution<br />
implementation using notations.  The class diagrams makes the understandability of the project flow and the pictorially represents the different classes used and how they were connected to each other  and which are all the classes that depends on the other classes can be represented.</p>
<p class="MsoNormal" style="text-indent:.5in">The class diagram can be represented by following notation and it does mainly have 3 parts first part is the name of the class, the second box or part is declaration of members or variables which are used in the class, the third part/box will be list of all the methods which are implemented in the class in order to perform the operations on class data members.</p>
<p class="MsoNormal">The following notations are used in drawing class diagrams.</p>
<p><img class="aligncenter size-medium wp-image-214" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image0071-300x133.jpg" alt="image0071" width="300" height="133" /></p>
<p class="MsoNormal" style="text-indent:.5in">The Class diagrams can be used to represent all the available variants of classes in Object oriented languages.</p>
<p class="MsoNormal" style="text-indent:.5in">The example class diagram used in web based video conferencing system.</p>
<p class="MsoNormal" style="text-indent:.5in"><img class="aligncenter size-medium wp-image-215" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image008-300x157.jpg" alt="image008" width="300" height="157" /></p>
<p class="MsoNormal" style="text-indent:.5in">In this diagram, as we can see the class is of type public and class name is enter_002dconf2_jsp used in web based video conferencing system, the member of the class is<strong> _dependants</strong> of  type Vector and access mode is private.</p>
<p class="MsoNormal" style="text-indent:.5in"><img class="aligncenter size-medium wp-image-216" src="http://blogs.circlesource.com/wp-content/uploads/2009/02/image009-300x119.jpg" alt="image009" width="300" height="119" /></p>
<p class="MsoNormal" style="text-indent:.5in">The two methods are defined of type public in order to perform the required operation, the <strong>getDependants() ,</strong><br />
method will get all the necessary dependents needed to start the video conferencing service, and the second method will <strong>_jspService()</strong> will start the service and write the required information on to the browser, if the required dependents are present then the client application will run through which the user can able to perform video conferencing, if not then the<br />
necessary information will be written on to the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/02/02/uml-usecase-diagrams-and-class-diagrams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Identification of IPV4 and IPV6</title>
		<link>http://blogs.circlesource.com/2009/01/24/identification-of-ipv4-and-ipv6/</link>
		<comments>http://blogs.circlesource.com/2009/01/24/identification-of-ipv4-and-ipv6/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 19:37:46 +0000</pubDate>
		<dc:creator>Asif Mohammad</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[GetHostAddresses()]]></category>
		<category><![CDATA[GetHostEntry()]]></category>
		<category><![CDATA[IPV4]]></category>
		<category><![CDATA[IPV4 vs IPV6]]></category>
		<category><![CDATA[IPV6]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[what is IPV4]]></category>
		<category><![CDATA[what is IPV6]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=171</guid>
		<description><![CDATA[
IPV4 vs IPV6:
 
Problem Scenario: I was involved in developing an windows application which suppose to work on    windows 2003, windows xp or earlier version. But at the time of deploying the application to the one machine which is using Windows Vista as OS, my application crashes. It is not getting started. But the same [...]]]></description>
			<content:encoded><![CDATA[<p><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--></p>
<p><strong><span style="font-family: Calibri;">IPV4 vs IPV6:</span></strong></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="font-family: Calibri;">Problem Scenario</span></strong><span style="font-family: Calibri;">: I was involved in developing an windows application which suppose to work on    windows 2003, windows xp or earlier version. But at the time of deploying the application to the one machine which is using Windows Vista as OS, my application crashes. It is not getting started. But the same application is working in other Test system having Vista OS.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="font-family: Calibri;">Solution</span></strong><span style="font-family: Calibri;">: <span> </span>After digging into the code I finally found the problem. Before starting, the application it collects few system information’s like Host Name, Host IP address etc and saves into the database. And Client Vista system is using IPV6 format address where as the application is expecting IPV4 address format. Here I came across the need to fetch the IPV4 address if some system is using IPV6 address.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="font-family: Calibri;">What are IPV4 and IPV6?</span></strong></p>
<p class="MsoNormal"><span style="font-family: Calibri;">IPv6 stands for Internet Protocol version 6</span><span style="font-family: Calibri;"> which is the next-generation Internet Layer protocol for packet-switched internetworks and the Internet. IPv4 is currently<sup><span style="display: none;"><a title="http://en.wikipedia.org/w/index.php?title=IPv6&amp;action=edit" href="http://en.wikipedia.org/w/index.php?title=IPv6&amp;action=edit">[update]</a></span></sup> the dominant Internet Protocol version, and was the first to receive widespread use. In December 1998, the Internet Engineering Task Force (IETF) designated IPv6 as the successor to version 4 by the publication of a Standards Track specification.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="font-family: Calibri;">Get Into the problem</span></strong><span style="font-family: Calibri;">.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">In my application it is expecting IPV4 address format, which can be split into four sections by “<strong>.</strong>” character and each section represents an integer. On the contrary IPv6 address size is 128 bits and the preferred IPv6 address representation is: </span><tt><span style="font-family: Calibri;">xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx</span></tt><span style="font-family: Calibri;"> where each </span><tt><span style="font-family: Calibri;">x</span></tt><span style="font-family: Calibri;"> is a hexadecimal digit representing 4 bits. IPv6 addresses range from </span><tt><span style="font-family: Calibri;">0000:0000:0000:0000:0000:0000:0000:0000</span></tt><span style="font-family: Calibri;"> to </span><tt><span style="font-family: Calibri;">ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff</span></tt><span style="font-family: Calibri;">. So we need to fetch list of all ip addresses on the host system and fetch the V4 representation of IP address.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Calibri;">Code to fetch the V4 representation of IP address:</span></span></strong></p>
<p class="MsoNormal"><span style="font-family: Calibri; color: blue;">Dim</span><span style="font-family: Calibri;"> IP4Address <span style="color: blue;">As</span> <span style="color: blue;">String</span> = <span style="color: blue;">String</span>.Empty</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span><span style="color: blue;">For</span> <span style="color: blue;">Each</span> IPA <span style="color: blue;">As</span> IPAddress <span style="color: blue;">In</span> Dns.GetHostAddresses(Dns.GetHostName())</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span><span style="color: blue;">If</span> IPA.AddressFamily.ToString() = <span style="color: maroon;">&#8220;InterNetwork&#8221;</span> <span style="color: blue;">Then</span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span>IP4Address = IPA.ToString()</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span><span> </span><span style="color: blue;">Exit</span> <span style="color: blue;">For</span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span><span style="color: blue;">End</span> <span style="color: blue;">If</span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span><span style="color: blue;">Next</span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri; color: blue;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">The <span class="selflink">GetHostAddresses()</span> method queries a DNS server for the IP addresses associated with a host name</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">For V4 comes under address family “InterNetwork”.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">Also we can serve the same purpose by using Dns. GetHostByName() method but it advisable to GetHostEntry() or GetHostAddresses() method as GetHostByName() become obsolete. Also we can use “IsIPv6SiteLocal”, “</span><span style="font-family: Calibri;">IsIPv6LinkLocal”</span><span style="font-family: Calibri;"> properties of IPAddress to determine if the current address is V6 format.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/01/24/identification-of-ipv4-and-ipv6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic Menu Creation In Windows (c#)</title>
		<link>http://blogs.circlesource.com/2009/01/20/dynamic-menu-creation/</link>
		<comments>http://blogs.circlesource.com/2009/01/20/dynamic-menu-creation/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 06:31:22 +0000</pubDate>
		<dc:creator>eduru.suneel</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Create Dynamic Menu In Windows]]></category>
		<category><![CDATA[Create Menu In Windows]]></category>
		<category><![CDATA[Dynamic Menu Creation In Windows]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=151</guid>
		<description><![CDATA[Download: dynamicmenuscreation.zip
Introduction
 
· Menus make it easy to access the functionality and take less space and make your application look more organized.
· Menus contain top – level items and drop &#8211; down items. 
o Top – level items: all visible items are top-level menus 
o Drop &#8211; down items: non – visible items are dropdown [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: right;"><strong>Download: <a rel="attachment wp-att-154" href="http://blogs.circlesource.com/2009/01/20/dynamic-menu-creation/dynamicmenuscreation/">dynamicmenuscreation.zip</a></strong></p>
<p><strong><span style="text-decoration: underline;"><span style="font-family: Tahoma;">Introduction</span></span></strong></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Tahoma;"><span style="text-decoration: none;"> </span></span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Menus make it easy to access the functionality and take less space and make your application look more organized.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Menus contain top – level items and drop &#8211; down items. </span></p>
<p class="MsoNormal" style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: &quot;Courier New&quot;;"><span>o<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Top – level items: all visible items are top-level menus </span></p>
<p class="MsoNormal" style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: &quot;Courier New&quot;;"><span>o<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Drop &#8211; down items: non – visible items are dropdown menus and also call it as child menus of a top – level menu.</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Tahoma;">Classes required to create a Menu</span></span></strong></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma; color: #2b91af;">1. MenuStrip:</span></strong><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">This control is like a container will hold all the top – level menus going to be created.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">This control will be available under <strong>“<span>System.Windows.Forms” </span></strong><span>namespace.</span></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: Tahoma;">Decalration of a MenuStrip control</span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="font-size: 10pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 10pt; font-family: Tahoma;">Import the namespace &#8211; </span><span style="font-size: 9pt; font-family: Tahoma; color: blue;">using</span><span style="font-size: 9pt; font-family: Tahoma;"> System.Windows.Forms</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: green;">// Declare the menustrip object.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: #2b91af;">MenuStrip</span><span style="font-size: 9pt; font-family: Tahoma;"> menuItems = <span style="color: blue;">new</span> <span style="color: #2b91af;">MenuStrip</span>();</span><strong></strong></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span></span></p>
<p class="MsoNormal" style="margin-left: 1.5in; text-indent: -1.5in;"><strong><span style="font-size: 9pt; font-family: Tahoma; color: #2b91af;">2. ToolStripMenuItem : </span></strong></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">This class is used to create menu items like top – level or drop – down menus going to be created.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;" lang="EN">It can also represent a submenu of another <code><span style="font-family: Tahoma;">ToolStripMenuItem</span></code> object. <code><span style="font-family: Tahoma;">ToolStripMenuItem</span></code> objects are viewed by the user, whereas a <code><span style="font-family: Tahoma;">MenuStrip</span></code> object simply establishes a container where menu items appear.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">This class will be available under <strong>“<span>System.Windows.Forms” </span></strong><span>namespace.</span></span></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: Tahoma;">Decalration of a MenuItem class</span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: Tahoma;"><span style="text-decoration: none;"> </span></span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;">Menu can be created using a Text or Image or both.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: Tahoma;"><span style="text-decoration: none;"> </span></span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: green;">// Take a ToolStripMenuItem to add the menu item with string.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: #2b91af;">ToolStripMenuItem</span><span style="font-size: 9pt; font-family: Tahoma;"> menuItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">ToolStripMenuItem</span>(<span style="color: #a31515;">&#8220;File&#8221;</span>);</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;">Or</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: green;">// Take a ToolStripMenuItem to add the menu item with Image.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: #2b91af;">ToolStripMenuItem</span><span style="font-size: 9pt; font-family: Tahoma;"> menuItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">ToolStripMenuItem</span>(<span style="color: blue;">new</span> <span style="color: #2b91af;">Bitmap</span>(<span style="color: #a31515;">&#8220;path of the image to load&#8221;</span>));<strong></strong></span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="text-decoration: underline;"><span style="font-size: 9pt; font-family: Tahoma;"><span style="text-decoration: none;"> </span></span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;">Or</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><strong><span style="font-size: 9pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: green;">// Take a ToolStripMenuItem to add the menu item with Strng and Image.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma; color: #2b91af;">ToolStripMenuItem</span><span style="font-size: 9pt; font-family: Tahoma;"> menuItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">ToolStripMenuItem</span>((<span style="color: #a31515;">&#8220;File&#8221;, </span><span style="color: blue;">new</span> <span style="color: #2b91af;">Bitmap</span>(<span style="color: #a31515;">&#8220;path of the image to load&#8221;</span>));<strong></strong></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;">These are the main classes to create any kind of menu.</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;">Using this information will know how to create dynamic menus.</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma;">Program: Going to create dynamic simple menus</span></strong></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><strong><span style="font-size: 9pt; font-family: Tahoma;">Output: </span></strong><span style="font-size: 9pt; font-family: Tahoma;">looks like this</span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span></span><strong><span style="font-family: Tahoma;">File<span> </span>Edit<span> </span>Help</span></strong><strong><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>-<span> </span></span></strong><span style="font-size: 9pt; font-family: Tahoma;">Top – level menus</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><strong>New<span> </span>Copy<span> </span>AboutMe<span> </span>-<span> </span></strong>drop – down menus<strong></strong></span></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>Open<span> </span>Cut<span> </span>ContactUs</span></strong></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>Exit<span> </span>Pate<span> </span>Help</span></strong></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal"><strong><span style="font-size: 9pt; font-family: Tahoma;"> </span></strong></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-size: 9pt; font-family: Tahoma;">Step-By-Step code explanation to create a dynamic menu</span></span></strong></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Tahoma;"><span>1.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Define menus required. </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><strong><span style="font-size: 9pt; font-family: Tahoma; color: red;">Note:</span></strong><span style="font-size: 9pt; font-family: Tahoma; color: red;"> There will be so many ways to approach declaring the menu items but here I used by taking dictionary object.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: green;">//<span> </span>Create Main menu and child menus in a ditcionary object as key pair values.</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #2b91af;">Dictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>[]&gt; displayMenus = <span style="color: blue;">new</span> <span style="color: #2b91af;">Dictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>[]&gt;();</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Define the child menus based on the each main menu on the basis of key.</span></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>displayMenus.Add(<span style="color: #a31515;">&#8220;File&#8221;</span>, <span style="color: blue;">new</span> <span style="color: blue;">string</span>[] { <span style="color: #a31515;">&#8220;New&#8221;</span>, <span style="color: #a31515;">&#8220;Open&#8221;</span>, <span style="color: #a31515;">&#8220;Exit&#8221;</span> });</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>displayMenus.Add(<span style="color: #a31515;">&#8220;Edit&#8221;</span>, <span style="color: blue;">new</span> <span style="color: blue;">string</span>[] { <span style="color: #a31515;">&#8220;Copy&#8221;</span>, <span style="color: #a31515;">&#8220;Cut&#8221;</span>, <span style="color: #a31515;">&#8220;Paste&#8221;</span> });</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">displayMenus.Add(<span style="color: #a31515;">&#8220;Help&#8221;</span>, <span style="color: blue;">new</span> <span style="color: blue;">string</span>[] { <span style="color: #a31515;">&#8220;AboutMe&#8221;</span>, <span style="color: #a31515;">&#8220;ContactUs&#8221;</span>, <span style="color: #a31515;">&#8220;Help&#8221;</span> });</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Tahoma;"><span>2.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Write a function to create menus by taking the dictionary object as parameter.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;summary&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>This method will create a menu based on the menus </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>and it&#8217;s submenus defined.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/summary&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;param name=&#8221;displayMenus&#8221;&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>Menus and it&#8217;s submenus in a dictioanry object</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/param&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;returns&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>Returns a collection of a toolstripmennu items.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/returns&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: blue;">private</span><span style="font-size: 9pt; font-family: Tahoma;"> <span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">ToolStripMenuItem</span>&gt; CreateMenu(<span style="color: #2b91af;">Dictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>[]&gt; displayMenus)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Declare ToolStripMenuItem object.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">ToolStripMenuItem</span>&gt; menuItems = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">ToolStripMenuItem</span>&gt;();</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Loop through all main menus.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">foreach</span> (<span style="color: #2b91af;">KeyValuePair</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">string</span>[]&gt; menu <span style="color: blue;">in</span> displayMenus)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Take a ToolStripMenuItem to add the menu item.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #2b91af;">ToolStripMenuItem</span> menuItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">ToolStripMenuItem</span>(menu.Key);</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Set a name to the menu.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>menuItem.Name = menu.Key;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Create child menu items for a menu item.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">this</span>.CreateChildMenus(menuItem, menu.Value);</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">switch</span> (menu.Key)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;File&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Edit&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// This is by default.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span> </span><span style="color: green;">// menuItem.Alignment = ToolStripItemAlignment.Left;</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Help&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>menuItem.Alignment = <span style="color: #2b91af;">ToolStripItemAlignment</span>.Right;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Add each menu item to the menu strip item.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>menuItems.Add(menuItem);</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">return</span> menuItems;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">}</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Tahoma;"><span>3.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Write a function to create child menus by taking the parent menu and the child menus going to be created.</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;summary&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>Thsi method will create a child menus of a menu item.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/summary&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;param name=&#8221;parentMenuToAddChildMenus&#8221;&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>Parent menu item to add child menu items.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/param&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;param name=&#8221;childMenus&#8221;&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>Child menu items going to be created.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/param&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: blue;">private</span><span style="font-size: 9pt; font-family: Tahoma;"> <span style="color: blue;">void</span> CreateChildMenus(<span style="color: #2b91af;">ToolStripMenuItem</span> parentMenuToAddChildMenus, <span style="color: blue;">string</span>[] childMenus)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Loop through all child menus.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> childMenu <span style="color: blue;">in</span> childMenus)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Take a ToolStripMenuItem to add the menu item.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #2b91af;">ToolStripMenuItem</span> childMenuItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">ToolStripMenuItem</span>(childMenu);</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Set a name to the menu.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>childMenuItem.Name = childMenu;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Hnadle the event for the menu created.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>childMenuItem.Click += <span style="color: blue;">new</span> <span style="color: #2b91af;">EventHandler</span>(ChildMenu_Click);</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">//<span> </span>Add each child menu to its parent menu item.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>parentMenuToAddChildMenus.DropDown.Items.Add(childMenuItem);</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>}</span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">}</span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.25in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Tahoma;"><span>4.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">Write an event handler common to all the menu items.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;summary&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"><span> </span>This method will handle the click event for each menu.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/summary&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;param name=&#8221;sender&#8221;&gt;</span><span style="font-size: 9pt; font-family: Tahoma; color: green;">Tool strip menu item.</span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/param&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: gray;">///</span><span style="font-size: 9pt; font-family: Tahoma; color: green;"> </span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;param name=&#8221;e&#8221;&gt;</span><span style="font-size: 9pt; font-family: Tahoma; color: green;">Event args.</span><span style="font-size: 9pt; font-family: Tahoma; color: gray;">&lt;/param&gt;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: blue;">private</span><span style="font-size: 9pt; font-family: Tahoma;"> <span style="color: blue;">void</span> ChildMenu_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #2b91af;">ToolStripMenuItem</span> sourceMenuItem = (<span style="color: #2b91af;">ToolStripMenuItem</span>)sender;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">string</span> selectedMenu = <span style="color: blue;">string</span>.Empty;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Selected menu item</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">switch</span> (sourceMenuItem.Name)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;New&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Open&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Exit&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Edit&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Copy&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Paste&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;AboutMe&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;ContactUs&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">case</span> <span style="color: #a31515;">&#8220;Help&#8221;</span>:</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: green;">// Required statements here.</span></span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu = sourceMenuItem.Text;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">break</span>;</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>}</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: blue;">if</span> (!<span style="color: blue;">string</span>.IsNullOrEmpty(selectedMenu))</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>{</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: blue;">string</span>.Concat(</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>selectedMenu,</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span><span style="color: #a31515;">&#8221; feature is under development &#8220;</span>));</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;"><span> </span>}</span></p>
<p class="MsoNormal" style="text-indent: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma;">}<span> </span></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Tahoma;"><span>5.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">add the created menu items collection to the <strong><span style="color: #2b91af;">MenuStrip</span></strong><span style="color: #2b91af;"> </span>object</span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: Tahoma;"> </span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Tahoma;">Conclusion:</span></span></strong></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Tahoma;"><span style="text-decoration: none;"> </span></span></span></strong></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">This is the procedure to create dynamic menus in windows application.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-size: 9pt; font-family: Symbol;"><span>·<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"> </span></span></span><!--[endif]--><span style="font-size: 9pt; font-family: Tahoma;">If you want to create your custom type dynamic menus then modify the code according to your needs in a dictionary object as defined in <strong><span style="color: red;">step1</span></strong>.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 9pt; font-family: Tahoma; color: red;">Note: This is just a sample code to guide you how a menu can be created.</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;">
<p class="MsoNormal" style="margin-left: 0.5in; text-align: right;"><strong>Download: <a rel="attachment wp-att-154" href="http://blogs.circlesource.com/2009/01/20/dynamic-menu-creation/dynamicmenuscreation/">dynamicmenuscreation.zip</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/01/20/dynamic-menu-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding forms inside a form in windows application</title>
		<link>http://blogs.circlesource.com/2009/01/20/embedding-forms-inside-a-form-in-windows-application/</link>
		<comments>http://blogs.circlesource.com/2009/01/20/embedding-forms-inside-a-form-in-windows-application/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 01:29:07 +0000</pubDate>
		<dc:creator>Asif Mohammad</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Embedding forms inside a form]]></category>
		<category><![CDATA[find page in panel]]></category>
		<category><![CDATA[TopLevel]]></category>
		<category><![CDATA[Use multiple form in a single form]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=128</guid>
		<description><![CDATA[
Embedding forms inside a form in windows application: 
Problem Scenario:
Let me first give a brief introduction of the problem so that we can understand better about the context of the solution.
In one of my project, I need to wrap up an old application with the new features and functionalities. But the problem I faced is, [...]]]></description>
			<content:encoded><![CDATA[<p><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--[if !mso]&gt;--></p>
<p><strong><span style="text-decoration: underline;"><span style="font-size: 14pt; font-family: Calibri;">Embedding forms inside a form in windows application: </span></span></strong></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Calibri;">Problem Scenario:</span></span></strong></p>
<p class="MsoNormal"><span style="font-family: Calibri;">Let me first give a brief introduction of the problem so that we can understand better about the context of the solution.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">In one of my project, I need to wrap up an old application with the new features and functionalities. But the problem I faced is, in every form, customer wants two new sections to be added and those two sections will remain fixed for all the forms. </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Calibri;">Solution: </span></span></strong></p>
<p class="MsoNormal"><span style="font-family: Calibri;">The options I left with is either to edit each form and add those two section to each form<span> </span>or we can have a MDI form or a simple form and divide it into three sections.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">Top and side left portion will be fixed and in bottom right portion, different forms will be loaded and unloaded as per the triggered events from other two sections. Also we need to make right bottom corner scrollable. </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">We adopt the second solution and there by came across the need for “<strong>Embedding a form inside a form”.</strong></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">The goal is to achive an effect like we have with Master page scenario in asp 2.0. where we can have common fixed portion appearing for all pages. These are useful for many <span> </span>scenarios such as having side menu bar etc. To achieve the goal I chose MDI form having divided into sections by number of panels (in my case it’s three) and load the user controls for the portions which are going to be fixed. According to the triggered events on those user controls we can load unload forms on the third panel.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Calibri;">Started With:</span></span></strong></p>
<p class="MsoNormal"><span style="font-family: Calibri;">We can embed form within another form or within a MDI form. Both the approach is basically same except few differences. But let understand the difference between adding a control and a form to another form. Control can be added at design time by drag drop or at run time using Me.controls.add() method. But in case of embedding a form within a form we have to do it in run time, but before that we need to have a container control like panel, as we can not just use <span style="color: blue;">Me</span>.controls.add. In case of MDI form we can use Controls. Add () method but that wont server our purpose.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span></span></p>
<p class="MsoNormal"><strong><span style="text-decoration: underline;"><span style="font-family: Calibri;">Steps to embed form within an MDI form</span></span></strong></p>
<p class="MsoNormal"><span style="text-decoration: underline;"><span style="font-family: Calibri;"><span style="text-decoration: none;"> </span></span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span>As discussed above let say we have a MDI form with name “frmMDI” which has three panels: &#8211; pnl1, pnl2 and pnl3.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">To add user controls to the panels we can use</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">Pnl1.Controls.Add (instance of user control)</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">But to add form to panel let say pnl3 below is the steps need to follow</span></p>
<p class="MsoNormal">
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue;">Dim</span><span style="font-family: &quot;Courier New&quot;;"> sampleOne <span style="color: blue;">As</span> <span style="color: blue;">New</span> frmSampleOne</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.MdiParent = frmMDI</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.TopLevel = <span style="color: blue;">False</span></span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.FormBorderStyle = Windows.Forms.FormBorderStyle.None</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.AutoScroll = <span style="color: blue;">True</span></span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.Dock = DockStyle.Fill<span> </span>frmMDI.pnlFrm.Controls.Add(GeneticHx)</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.Show()</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.WindowState = FormWindowState.Normal</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="text-decoration: underline;"><span style="font-family: Calibri;">lets discuss the steps: </span></span></p>
<p class="MsoNormal"><span style="text-decoration: underline;"><span style="font-family: Calibri;"><span style="text-decoration: none;"> </span></span></span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">1. First need to instantiate the form </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">2. Set the Mdi parent to the frmMDI so that you can use “ActiveMdiChild” fi needed</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">3. We need to set the TopLevel property of the form to false. By default the TopLevel property of the form is true. This property indicates whether to display the form as a top-level window. A top-level form is a window that has no parent form, or whose parent form is the desktop window. Top-level windows are typically used as the main form in an application. So if we do not set the TopLevel property to false it will throw exception as the form is going to add under a container control like Panel or MDI form.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">4. Set FormBorderStyle to none to remove the upper action bar.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">5. Set the AutoScroll to true. This is needed to for scrolling to appear. Here we need to understand that scrolling appears on the form which is getting added not on the panel. Here the AutoScroll property for the form means that if the form exceeds the size of its parent control (here pnl3) scrolling appears.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">6. Set the Dock property “fill” so that it can acquire the whole space under the panel</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">7. Add the form object into the panel by Controls.Add() method</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">8. Invoke the show () methode on the form object to make the form loaded.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">9. Set the WindowState property to Normal. This very important for the scrolling to come. If we set the WindowState to maximum, scrolling will not come for form .</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">Also one point is worth mentionable here is that if you are adding a form and that form itself has one or more panels then make sure that the Dock property of those panel set to None. if not scrolling will not appear for that form.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">As we have now finished with adding form under a panel now let’s see how we can load and unload forms and invoking events on those forms from out side panel. Let say as per our example on click of a button on pnl2 I need to close the form under pnl3 if any and load frmSampleTwo in that panel.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"><span> </span>For the above mentioned situation first we need to access the form instance in the panel. </span></p>
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue;">Dim</span><span style="font-family: &quot;Courier New&quot;;"> sampleOne <span style="color: blue;">As</span> frmSampleOne</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue;">Dim</span><span style="font-family: &quot;Courier New&quot;;"> ctl <span style="color: blue;">As</span> <span style="color: blue;">New</span> Control</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue;">If</span><span style="font-family: &quot;Courier New&quot;;"> frmMDI.pnl3.Controls.Find(“frmSampleOne”, <span style="color: blue;">True</span>).Length &gt; 0 <span style="color: blue;">Then</span></span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">ctl = frmMDI.pnl3.Controls.Find((“frmSampleOne”, <span style="color: blue;">True</span>)(0)</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne = <span style="color: blue;">CType</span>(ctl, Form)</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">Follow the steps as mentioned above for adding new form (frmSampleTwo) in pnl3</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;">sampleOne.close()</span></p>
<p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; color: blue;">End</span><span style="font-family: &quot;Courier New&quot;;"> <span style="color: blue;">If</span></span></p>
<p class="MsoNormal">
<p class="MsoNormal"><span style="font-family: Calibri;">As the above code shows once we get the instance of the form under pnl3 we can invoke any events and methods having public modifier.</span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">It’s always good to load the next form before closing the existing one to avoid flickering effect. That’s the reason we load frmSampleTwo before invoking close () method on sampleOne. </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;"> </span></p>
<p class="MsoNormal"><span style="font-family: Calibri;">By applying above concept we can divide a form into sections and can load more than one form under each section.</span></p>
<p class="MsoNormal">
<p class="MsoNormal">
<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/01/20/embedding-forms-inside-a-form-in-windows-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Velocity Usages and its advantages</title>
		<link>http://blogs.circlesource.com/2009/01/20/velocity-usages-and-its-advantages/</link>
		<comments>http://blogs.circlesource.com/2009/01/20/velocity-usages-and-its-advantages/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 01:22:47 +0000</pubDate>
		<dc:creator>srinivas.reddy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[microsoft distbruted velocity]]></category>
		<category><![CDATA[Microsoft distributed velocity]]></category>
		<category><![CDATA[velocity]]></category>
		<category><![CDATA[Velocity(Cache)]]></category>

		<guid isPermaLink="false">http://blogs.circlesource.com/?p=114</guid>
		<description><![CDATA[ 
 
Using Velocity and its advantages
 
It’s a distributed system. Velocity provides highly scalable distributed caching environment for Microsoft .net framework. By using this we can store frequently used data for faster access and also avoids unnecessary calls to the database. Velocity also supports optimistic and pessimistic locking as well as automatic load balancing.
We [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><strong><span style="font-size: small;"><span style="font-family: Times New Roman;">Using Velocity and its advantages</span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">It’s a distributed system. Velocity provides highly scalable distributed caching environment for Microsoft .net framework. By using this we can store frequently used data for faster access and also avoids unnecessary calls to the database. Velocity also supports optimistic and pessimistic locking as well as automatic load balancing.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">We can use velocity either in windows application or web application.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Microsoft provides velocity in the form of a cluster. In this section we look at what are all those useful elements having cluster, how cluster works and some useful programming with velocity.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">In velocity one of the major element is named cache by using this we can store logical grouping of data like a database. A cluster can have any no of named caches. We can use one or more named caches in our applications. We can directly store objects in a cache without creating named cache. In this case those objects are stored in default named cache of the cluster.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">We can create or delete the cache using velocity administration tool</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Example: Create Cache CacheSample</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span>Delete Cache CacheSample</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small; font-family: Times New Roman;">Here CacheSample is the name of the cache</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Another major (optional) element is regions. Actually regions are logical grouping of objects in a named cache like database tables. Regions provide additional searching capabilities. We can create any no of regions on a named cache. Regions are not possible to create using administration tool. We must be creating a region using explicitly run time using application. </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">We can also check what are all those regions inside the caches and regions available in a cluster using this below command</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Example:<strong> </strong>List Host CacheSample</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Velocity allows blindly any time of CLR serialized object in the form of key value pairs</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Regions can store any no of objects but depend on size of cluster installation. Anyway once we are added object in a cache that object resides in a cache including version, time to live (TTL) and tags.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><strong><span style="font-size: small;"><span style="font-family: Times New Roman;">The below example describes how to add item to the cache and get the item from cache.</span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><strong><span style="font-size: small; font-family: Times New Roman;"> </span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><strong>Step 1 </strong>First run velocity setup and then references the following .dll from the Program Files\Microsoft Distributed Cache folder: CacheBaseLibrary.dll, ClientLibrary.dll, FabricCommon.dll, CASBase.dll, and CASClient.dll to visual studio .net project.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><strong>Step 2</strong> We also need to add the below configuration information to app.Config file or Web.Config file.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Example:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">configSections</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">section</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">name</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">dcacheClient</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">type</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">System.Configuration.IgnoreSectionHandler</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">allowLocation</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">true</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">allowDefinition</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">Everywhere</span>&#8220;<span style="color: blue;"> /&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">section</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">name</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">fabric</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">type</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">System.Fabric.Common.ConfigFile, FabricCommon</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">allowLocation</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">true</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">allowDefinition</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">Everywhere</span>&#8220;<span style="color: blue;"> /&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&lt;/</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">configSections</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">dcacheClient</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">deployment</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">simple</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">localCache</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">false</span>&#8220;<span style="color: blue;">&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">hosts</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;!&#8211;</span><span style="font-size: 10pt; color: green; mso-no-proof: yes;">List of hosts </span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&#8211;&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">host</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">name</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;NameOfCacheServerSystem&#8221;<span style="color: blue;"> </span><span style="color: red;">cachePort</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">22233</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">cacheHostName</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">DistributedCacheService</span>&#8220;<span style="color: blue;"> /&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;/</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">hosts</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&lt;/</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">dcacheClient</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">fabric</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">section</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">name</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">logging</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">path</span><span style="color: blue;">=</span>&#8220;&#8221;<span style="color: blue;">&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">collection</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">name</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">sinks</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">collectionType</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">list</span>&#8220;<span style="color: blue;">&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">customType</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">className</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">System.Fabric.Common.EventLogger,FabricCommon</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">sinkName</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">System.Fabric.Common.ConsoleSink,FabricCommon</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">sinkParam</span><span style="color: blue;">=</span>&#8220;&#8221;<span style="color: blue;"> </span><span style="color: red;">defaultLevel</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">-1</span>&#8220;<span style="color: blue;"> /&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">customType</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">className</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">System.Fabric.Common.EventLogger,FabricCommon</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">sinkName</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">System.Fabric.Common.FileEventSink,FabricCommon</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">sinkParam</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">CacheClientLog</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">defaultLevel</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">1</span>&#8220;<span style="color: blue;"> /&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">customType</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"> </span><span style="font-size: 10pt; color: red; mso-no-proof: yes;">className</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">=</span><span style="font-size: 10pt; mso-no-proof: yes;">&#8220;<span style="color: blue;">System.Fabric.Common.EventLogger,FabricCommon</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">sinkName</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">System.Data.Caching.ETWSink, CacheBaseLibrary</span>&#8220;<span style="color: blue;"> </span><span style="color: red;">sinkParam</span><span style="color: blue;">=</span>&#8220;&#8221;<span style="color: blue;"> </span><span style="color: red;">defaultLevel</span><span style="color: blue;">=</span>&#8220;<span style="color: blue;">-1</span>&#8220;<span style="color: blue;"> /&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;/</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">collection</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;/</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">section</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: blue; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span>&lt;/</span><span style="font-size: 10pt; color: #a31515; mso-no-proof: yes;">fabric</span><span style="font-size: 10pt; color: blue; mso-no-proof: yes;">&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><strong><span style="font-size: small; font-family: Times New Roman;"> </span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><strong>Step 3</strong> Needs to create a named cache from velocity administration tool</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small; font-family: Times New Roman;">Create Cache CacheSample</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small; font-family: Times New Roman;">Here ‘CacheSample’ is the named cache.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><strong>Step 4 </strong>Create<strong> </strong>the instance of the cache factory class and get the named cache from that instance.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">CacheFactory cacheFactory = new CacheFactory();</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;">Cache cache = <span style="mso-no-proof: yes;">cacheFactory</span>.GetCache(&#8220;CacheSample &#8220;);</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><strong>Step 5 </strong>create the region </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;">cache<span style="mso-no-proof: yes;">.CreateRegion(“SampleRegion”,true); </span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><strong>Step 6<span style="mso-no-proof: yes;"> </span></strong>Add<span style="mso-no-proof: yes;"> </span>the item(object) to the region<span style="mso-no-proof: yes;"> </span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">We can add any CLR serialized object by using Add and Put methods.The main difference between Add and Put is Add will throw an error if given key is already exists but put will not throw any exception if the given key is already exists its replace with newer one. On the other hand if the given key is does not exist the object will be added to the cluster.</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">ADD Method</span></span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Name of the region in a named cache</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Key for uniquely identify the<span style="mso-spacerun: yes;"> </span>cache object</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Cached object(in this case ds)</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Searchable information</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Version information</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Time to alive in cache interms of minutes</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small;"><span style="font-family: Times New Roman;">cache.<span style="mso-no-proof: yes;">Add(“SampleRegion”, “Id”, ds, searchInfo,15);</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">Put Method</span></span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Name of the region in a named cache</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Key for uniquely identify the<span style="mso-spacerun: yes;"> </span>cache object</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Cached object(in this case ds)</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Searchable information</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Version information</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Time to alive in cache interms of minutes</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: small;"><span style="font-family: Times New Roman;">cache<span style="mso-no-proof: yes;">.Put(“SampleRegion”, “Id”, ds, searchInfo, null, 15);</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">Get Method</span></span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Name of the region in a named cache</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Key for uniquely identify the<span style="mso-spacerun: yes;"> </span>cache object</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// It returns a cache Item Object. </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// That need to cast into appropriate type</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">CacheItem item = cache.GetCacheItem(“SampleRegion”, “Id”)</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="font-size: small; font-family: Times New Roman;"> </span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="font-size: small;"><span style="font-family: Times New Roman;">Remove the item from Cache</span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><strong><span style="font-size: small; font-family: Times New Roman;"> </span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">Remove method deletes object with specified key from the cache.<span style="mso-spacerun: yes;"> </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-spacerun: yes;"> </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt 0.75in; text-indent: -0.25in; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list .75in;"><span style="font-family: Times New Roman;"><strong><span style="mso-no-proof: yes;"><span style="mso-list: Ignore;"><span style="font-size: small;">1.</span><span style="font: 7pt &quot;Times New Roman&quot;;"> </span></span></span></strong><strong><span style="mso-no-proof: yes;"><span style="font-size: small;">Remove the object with specified key from cache</span></span></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-family: Times New Roman;"><span style="mso-no-proof: yes;"><span style="mso-spacerun: yes;"><span style="font-size: small;"> </span></span></span><span style="font-size: 10pt; color: green; mso-no-proof: yes;">// Unique key associated with the object.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span>cache.Remove(“Id”);</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-tab-count: 1;"> </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><strong><span style="mso-spacerun: yes;"> </span>2. Removes the Object with specified key from specified region</strong></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;"> </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Name of the region, cannot be null.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-family: Times New Roman;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;">// Unique key associated with the object</span><span style="mso-no-proof: yes;"><span style="font-size: small;">.</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;">cache.Remove(“SampleRegion”, “Id”);</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-spacerun: yes;"> </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><strong><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span>3. Drop the region with the specified name.</span></span></span></strong></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"><span style="mso-no-proof: yes;"><span style="font-size: small;"><span style="font-family: Times New Roman;"><span style="mso-spacerun: yes;"> </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// Name of the region, cannot be null.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"><span style="font-size: 10pt; color: green; mso-no-proof: yes;"><span style="font-family: Times New Roman;">// If it returns true then successful other wise returns false.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;"><span style="mso-no-proof: yes;"><span style="font-size: small; font-family: Times New Roman;">Cache.RemoveRegion(string region);</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: small; font-family: Times New Roman;"> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.circlesource.com/2009/01/20/velocity-usages-and-its-advantages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
