<?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; Asif Mohammad</title>
	<atom:link href="http://blogs.circlesource.com/author/itzasifmd/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>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>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>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>
	</channel>
</rss>
