<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3464107191210707975</id><updated>2024-08-28T03:39:13.668-07:00</updated><category term="C#"/><category term="Windows Application"/><category term="asp"/><category term="Class"/><category term="Dialog Controls"/><category term="Arrays"/><category term="Button Controls"/><category term="Data Base Application"/><category term="Attributes"/><category term="Chat"/><category term="Email Transfer"/><category term="Error Provider"/><category term="Events and Delegates"/><category term="Exception Handling"/><category term="Grid views"/><category term="Hidden Fields"/><category term="IIS"/><category term="Inheritance"/><category term="Interfaces"/><category term="Labelproperties"/><category term="Menustrip"/><category term="Methods"/><category term="Polymorphism"/><category term="Properties"/><category term="Random password generation"/><category term="Regular Expression"/><category term="Sql"/><category term="Table"/><category term="Text  box"/><category term="Tree View"/><title type='text'>ASP.NET WITH C#</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>66</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-7938123593664747320</id><published>2015-04-20T04:26:00.001-07:00</published><updated>2015-04-20T06:28:29.037-07:00</updated><title type='text'>How to use Crystal Report in WEB Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Select&amp;nbsp;CrystalReportViewer1 from tool box&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;printService printServ = new printService();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void printall()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Invoice = txt_invoice.Text;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReportDocument rptDoc = new ReportDocument();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataPurchase ds = new DataPurchase();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataTable dt = new DataTable();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt.TableName = &quot;Crystal Report Example&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt = printServ.getPurchaseMasterPrint(Invoice).Tables[0];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ds.Tables[0].Merge(dt);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Invoice = dt.Rows[0][0].ToString();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt = printServ.getPurchaseChildPrint(Convert.ToInt32(Invoice)).Tables[0];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ds.Tables[1].Merge(dt);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rptDoc.Load(Server.MapPath(&quot;~/Crystal/CrystalReportPurchase.rpt&quot;));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rptDoc.SetDataSource(ds);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CrystalReportViewer1.ReportSource = rptDoc;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rptDoc.PrintToPrinter(1, false, 0, 0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch { }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/7938123593664747320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-use-crystal-report-in-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7938123593664747320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7938123593664747320'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-use-crystal-report-in-web.html' title='How to use Crystal Report in WEB Application'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-1103918538976784811</id><published>2015-04-20T04:25:00.001-07:00</published><updated>2015-04-20T04:26:42.091-07:00</updated><title type='text'>How to use Crystal Report in Windows Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;u&gt;&lt;b&gt;How to use Crystal Report in Windows Application&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;u&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
Create a winform frmSales.cs&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Call&amp;nbsp;&lt;/u&gt;frmCrystal&lt;u&gt;&amp;nbsp;from Sales form&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; private void btnsave_Click(object sender, EventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp;frmCrystal frm = new frmCrystal();&lt;br /&gt;
&amp;nbsp;frm.print(sa.invoiceNo, grand);&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;u&gt;Create a winform frmCrystal.cs&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Drag and drop&amp;nbsp;crystalReportViewer1 in frmCrystal form&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTrfP14UOa9TJvYsA-XI0UKTZYfhyphenhyphenXW0YcHgyDWDRtwCRUxvaAVYl4WMNEGTnObRW0Io7ium4VA7qVghp0Xj2as448nMGcxOBDV5zGsq7PdWu_SxY_YzrbSP1j84M582uRxove2eQJeJo/s1600/print.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTrfP14UOa9TJvYsA-XI0UKTZYfhyphenhyphenXW0YcHgyDWDRtwCRUxvaAVYl4WMNEGTnObRW0Io7ium4VA7qVghp0Xj2as448nMGcxOBDV5zGsq7PdWu_SxY_YzrbSP1j84M582uRxove2eQJeJo/s1600/print.png&quot; height=&quot;179&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public void print(string invoiceno, string grand)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CrystalReport1 crpt = new CrystalReport1(); // DataSet&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DatasetSalesprint ds = new DatasetSalesprint();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataTable dt = new DataTable();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataTable dt1 = new DataTable();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt.TableName = &quot;Crystal Report Example&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt = getAllOrders(invoiceno).Tables[0];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ds.Tables[0].Merge(dt);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt = getmaster(invoiceno).Tables[0];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ds.Tables[1].Merge(dt);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt1.Columns.Add(&quot;grandtoword&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dt1.Rows.Add( grand);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ds.Tables[2].Merge(dt1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; crpt.SetDataSource(ds);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; crystalReportViewer1.ReportSource = crpt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;crpt.PrintToPrinter(2, false, 0, 0);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public DataSet getAllOrders(string invoiceno)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// string sqlCon = @&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Malabar.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string sqlCon = @&quot; Data Source=.\SQLEXPRESS;AttachDbFilename=E:\Data\Malabar.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SqlConnection Con = new SqlConnection(sqlCon);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SqlCommand cmd = new SqlCommand();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataSet ds = null;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SqlDataAdapter adapter;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Con.Open();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.CommandText = &quot;saleschildprint&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Parameters.Add(new SqlParameter(&quot;@invoiceNo&quot;, invoiceno));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //cmd.Parameters.Add(new SqlParameter(&quot;@Password&quot;, bUser.Password));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Connection = Con;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ds = new DataSet();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adapter = new SqlDataAdapter(cmd);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adapter.Fill(ds, &quot;child&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception ex)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new Exception(ex.Message);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; finally&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cmd.Dispose();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (Con.State != ConnectionState.Closed)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Con.Close();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return ds;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/1103918538976784811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-use-crystal-report-in-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1103918538976784811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1103918538976784811'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-use-crystal-report-in-windows.html' title='How to use Crystal Report in Windows Application'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTrfP14UOa9TJvYsA-XI0UKTZYfhyphenhyphenXW0YcHgyDWDRtwCRUxvaAVYl4WMNEGTnObRW0Io7ium4VA7qVghp0Xj2as448nMGcxOBDV5zGsq7PdWu_SxY_YzrbSP1j84M582uRxove2eQJeJo/s72-c/print.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-7299076050844755714</id><published>2015-04-17T09:05:00.003-07:00</published><updated>2015-07-22T00:01:02.107-07:00</updated><title type='text'>How to Upload an Image in Asp.net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp;HttpPostedFile myfile = FileUpload_productgroup.PostedFile;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int filelen = myfile.ContentLength;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int flag = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (filelen &amp;gt; 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (System.IO.Path.GetExtension(myfile.FileName).ToLower() == &quot;.jpg&quot; || System.IO.Path.GetExtension(myfile.FileName).ToLower() == &quot;.jpeg&quot; || System.IO.Path.GetExtension(myfile.FileName).ToLower() == &quot;.gif&quot; || System.IO.Path.GetExtension(myfile.FileName).ToLower() == &quot;.png&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string temp = Guid.NewGuid().ToString();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //temp = thpackser.gettourhoneymoonpackageid();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; filename = temp + System.IO.Path.GetExtension(FileUpload_productgroup.FileName);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String path = Server.MapPath(Request.ApplicationPath) + &quot;/mast/productimage/&quot; + filename;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FileUpload_productgroup.SaveAs(path);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pinfo.image1 = &quot;~&quot; + &quot;/mast/productimage/&quot; + filename;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag = 1;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (flag == 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Page.ClientScript.RegisterStartupScript(this.GetType(), &quot;new&quot;, &quot;alert(&#39;File format is not supported&#39;);&quot;, true);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (filelen == 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pinfo.image1 = &quot;&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/7299076050844755714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-upload-image-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7299076050844755714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7299076050844755714'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-upload-image-in-aspnet.html' title='How to Upload an Image in Asp.net'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-3865878807485505858</id><published>2015-04-17T08:59:00.001-07:00</published><updated>2015-04-20T06:34:27.927-07:00</updated><title type='text'>How to use LINQ to SQL in ASP.NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;background-color: white; box-sizing: border-box; color: #505050; font-family: wf_segoe-ui_light, &#39;Segoe UI Light&#39;, &#39;Segoe WP Light&#39;, wf_segoe-ui_normal, &#39;Segoe UI&#39;, Segoe, &#39;Segoe WP&#39;, Tahoma, Verdana, Arial, sans-serif; font-size: 18px; font-weight: 500; line-height: 22px; margin-bottom: 30px; margin-top: 30px;&quot;&gt;
&lt;u style=&quot;box-sizing: border-box;&quot;&gt;Modeling Databases Using LINQ to SQL:&lt;/u&gt;&lt;/h3&gt;
&lt;b&gt;&lt;u&gt;Select from the DB by using LINQ&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; /&lt;br /&gt;
select()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DataClassesDataContext db = new DataClassesDataContext();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var equipment = (from n in db.names&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where n.id == 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select n).FirstOrDefault();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TextBox2.Text = equipment.name1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gvCustomers.DataSource = db.names;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gvCustomers.DataBind();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;By Using Storedproceedure&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;
&amp;nbsp;var emptb = db.selectemployee(1).ToList();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;foreach (var r in emptb)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TextBox4.Text = r.empname;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gvCustomers.PageIndex = e.NewPageIndex;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.PopulateCustomers();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insert to the DB&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;protected void InsertButton_Click(object sender, EventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //insert&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name ord = new name&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name1 = TextBox2.Text,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; details = TextBox3.Text&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // …&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.names.InsertOnSubmit(ord);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Submit the change to the database.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.SubmitChanges();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.WriteLine(e);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Make some adjustments.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // ...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Try again.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.SubmitChanges();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
Update DB&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;protected void UpdateButton_Click(object sender, EventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var query =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; from ord in db.names&lt;br /&gt;
&amp;nbsp; &amp;nbsp; where ord.id == 3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; select ord;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Execute the query, and change the column values&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // you want to change.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (name ord in query)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ord.name1 = &quot;Noushad&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ord.details = &quot;aaaaa&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Insert any additional changes to column values.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Submit the changes to the database.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.SubmitChanges();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.PopulateCustomers();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.WriteLine(e);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Provide for exceptions.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
Delete to DB&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; protected void DeleteButton_Click(object sender, EventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var deleteOrderDetails =&lt;br /&gt;
&amp;nbsp; &amp;nbsp; from details in db.names&lt;br /&gt;
&amp;nbsp; &amp;nbsp; where details.id == 3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; select details;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (var detail in deleteOrderDetails)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.names.DeleteOnSubmit(detail);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; db.SubmitChanges();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.WriteLine(e);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Provide for exceptions.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;&lt;u&gt;Dropdown and Listbox&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;private void FillListBox(DataClassesDataContext db)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //LINQ syntax&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Select the ProductID and ProductName from Products&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var products = from c in db.names&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select new&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ID1 = c.id,&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NAME1 = c.name1,&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Bind the ListBox&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //ListBox1.DataSource = products;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //ListBox1.DataTextField = &quot;ProductName&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //ListBox1.DataValueField = &quot;ProductID&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //ListBox1.DataBind();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Bind the DropDownList&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dd2.DataSource = products;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dd2.AppendDataBoundItems = true;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dd2.Items.Add(&quot;Select&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dd2.DataTextField = &quot;NAME1&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dd2.DataValueField = &quot;ID1&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dd2.DataBind();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/3865878807485505858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-use-linq-to-sql-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/3865878807485505858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/3865878807485505858'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2015/04/how-to-use-linq-to-sql-in-aspnet.html' title='How to use LINQ to SQL in ASP.NET'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-8444444477514525501</id><published>2013-11-08T06:03:00.000-08:00</published><updated>2013-11-08T06:03:30.254-08:00</updated><title type='text'>ASP.NET AJAX Control Toolkit</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;Welcome to the ASP.NET AJAX Control Toolkit. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;Choose from any of the samples on the left to see the live controls in action, and experiment with their different possibilities. &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;subheading&quot;&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;What is the ASP.NET AJAX Control Toolkit?&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;The ASP.NET AJAX Control Toolkit is an open-source project built on top of the Microsoft ASP.NET AJAX framework. It is a joint effort between Microsoft and the ASP.NET AJAX community that provides a powerful infrastructure to write reusable, customizable and extensible ASP.NET AJAX extenders and controls, as well as a rich array of controls that can be used out of the box to create an interactive Web experience. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/8444444477514525501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2013/11/aspnet-ajax-control-toolkit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8444444477514525501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8444444477514525501'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2013/11/aspnet-ajax-control-toolkit.html' title='ASP.NET AJAX Control Toolkit'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-7090156741487258610</id><published>2011-07-05T03:28:00.000-07:00</published><updated>2011-07-05T03:28:15.314-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Exception Handling"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>Exception Handling in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
Exceptions are unforeseen errors that happen in your programs. Most of the time, you can, and should, detect and handle program errors in your code. For example, validating user input, checking for null objects, and verifying the values returned from methods are what you expect, are all examples of good standard error handling that you should be doing all the time.&lt;br /&gt;
However, there are times when you don&#39;t know if an error will occur. For example, you can&#39;t predict when you&#39;ll receive a file I/O error, run out of system memory, or encounter a database error. These things are generally unlikely, but they could still happen and you want to be able to deal with them when they do occur. This is where exception handling comes in.&lt;br /&gt;
When exceptions occur, they are said to be &quot;thrown&quot;. What is actually thrown is an object that is derived from the&amp;nbsp;&lt;i&gt;System.Exception&lt;/i&gt;&amp;nbsp;class. In the next section, I&#39;ll be explaining how thrown exceptions are handled with&amp;nbsp;&lt;i&gt;try/catch&lt;/i&gt;&amp;nbsp;blocks.&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;System.Exception&lt;/i&gt;&amp;nbsp;class provides several methods and properties for obtaining information on what went wrong. For example, the&amp;nbsp;&lt;i&gt;Message&lt;/i&gt;&amp;nbsp;property provides summary information about what the error was, the&amp;nbsp;&lt;i&gt;Stacktrace&lt;/i&gt;&amp;nbsp;property provides information from the stack for where the problem occurred, and the&amp;nbsp;&lt;i&gt;ToString()&lt;/i&gt;&amp;nbsp;method is overridden to reveal a verbose description of the entire exception.&lt;br /&gt;
Identifying the exceptions you&#39;ll need to handle depends on the routine you&#39;re writing. For example, if the routine opened a file with the&amp;nbsp;&lt;i&gt;System.IO.File.OpenRead()&lt;/i&gt;&amp;nbsp;method, it could throw any of the following exceptions:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;em&gt;SecurityException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;ArgumentException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;ArgumentNullException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;PathTooLongException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;DirectoryNotFoundException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;UnauthorizedAccessException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;FileNotFoundException&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;NotSupportedException&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;It&#39;s easy to find out what exceptions a method can raise by looking in the .NET Frameworks SDK Documentation. Just go to the Reference/Class Library section and look in the Namespace/Class/Method documentation for the methods you use. The exception in the list above were found by looking at the&amp;nbsp;&lt;i&gt;OpenRead()&lt;/i&gt;&amp;nbsp;method definition of the&amp;nbsp;&lt;i&gt;File&lt;/i&gt;&amp;nbsp;class in the&lt;i&gt;System.IO&lt;/i&gt;&amp;nbsp;namespace. Each exception identified has a hyperlink to its class definition that you can use to find out what that exception is about. Once you&#39;ve figured out what exceptions can be generated in your code, you need to put the mechanisms in place to handle the exceptions, should they occur.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;try/catch Blocks&lt;/h4&gt;When exceptions are thrown, you need to be able to handle them. This is done by implementing a&amp;nbsp;&lt;i&gt;try/catch&lt;/i&gt;&amp;nbsp;block. Code that could throw an exception is put in the&amp;nbsp;&lt;i&gt;try&lt;/i&gt;&amp;nbsp;block an exception handling code goes in the&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block. Listing 15-1 shows how to implement a&amp;nbsp;&lt;i&gt;try/catch&lt;/i&gt;&amp;nbsp;block. Since an&amp;nbsp;&lt;i&gt;OpenRead()&amp;nbsp;&lt;/i&gt;method could throw one of several exceptions, it is placed in the&amp;nbsp;&lt;i&gt;try&lt;/i&gt;block. If an exception is thrown, it will be caught in the&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block. The code in Listing 15-1 will print message and stack trace information out to the console if an exception is raised.&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;The programs in this lesson cause exceptions on purpose. The exception that you see is generated intentionally to show you what the exception message looks like before you see it yourself in your own programs.&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;Listing 15-1. Using try/catch Blocks: tryCatchDemo.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System.IO;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;tryCatchDemo&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File.OpenRead(&quot;NonExistentFile&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;(Exception ex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(ex.ToString());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
Although the code in Listing 15-1 only has a single&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block, all exceptions will be caught there because the type is of the base exception type &quot;Exception&quot;. In exception handling, more specific exceptions will be caught before their more general parent exceptions. For example, the following snippet shows how to place multiple catch blocks:&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;(FileNotFoundException fnfex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(fnfex.ToString());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;(Exception ex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(ex.ToString());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
If the file doesn&#39;t exist, a&amp;nbsp;&lt;i&gt;FileNotFoundException&lt;/i&gt;&amp;nbsp;exception will be thrown and caught by the first&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block. However, if a&amp;nbsp;&lt;i&gt;PathTooLongException&lt;/i&gt;&amp;nbsp;exception was raised, the second catch part would catch the exception. This is because there isn&#39;t a&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block for the&amp;nbsp;&lt;i&gt;PathTooLongException&lt;/i&gt;&amp;nbsp;exception and the generic&amp;nbsp;&lt;i&gt;Exception&lt;/i&gt;&amp;nbsp;type&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block is the only option available to catch the exception.&lt;br /&gt;
Exceptions that are not handled will normally bubble up the stack until a calling routine in the call chain handles them. If you forget to include&amp;nbsp;&lt;i&gt;try/catch&lt;/i&gt;&amp;nbsp;blocks in a part of your code and there aren&#39;t any&amp;nbsp;&lt;i&gt;try/catch&lt;/i&gt;&amp;nbsp;blocks earlier in the call chain, your program will abort with a message describing the exception. To your users this would be very cryptic and uncomfortable. It is good practice to provide exception handling in your programs.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Finally Blocks&lt;/h4&gt;An exception can leave your program in an inconsistent state by not releasing resources or doing some other type of cleanup. A&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block is a good place to figure out what may have gone wrong and try to recover, however it can&#39;t account for all scenarios. Sometimes you need to perform clean up actions whether or not your program succeeds. These situations are good candidates for using a&amp;nbsp;&lt;i&gt;finally&lt;/i&gt;&amp;nbsp;block.&lt;br /&gt;
Listing 15-2 illustrates the usefulness of a&amp;nbsp;&lt;i&gt;finally&lt;/i&gt;&amp;nbsp;block. As you know, a file stream must be closed when you&#39;re done with it. In this case, the file stream is the resource that needs to be cleaned up. In Listing 15-2,&amp;nbsp;&lt;i&gt;outStream&lt;/i&gt;&amp;nbsp;is opened successfully, meaning the program now has a handle to an open file resource. When trying to open the&amp;nbsp;&lt;i&gt;inStream&lt;/i&gt;, a&lt;i&gt;FileNotFoundException&lt;/i&gt;&amp;nbsp;exception is raised, causing control to go immediately to the&amp;nbsp;&lt;i&gt;catch&lt;/i&gt;&amp;nbsp;block.&lt;br /&gt;
It&#39;s possible to close the&amp;nbsp;&lt;i&gt;outStream&lt;/i&gt;&amp;nbsp;in the catch block, but what if the algorithm executed successfully without an exception?&amp;nbsp; On success, the file would never be closed. Fortunately, we&#39;ve included a&amp;nbsp;&lt;i&gt;finally&lt;/i&gt;&amp;nbsp;block in Listing 15-2, which will always be executed. That&#39;s right, regardless of whether the algorithm in the&amp;nbsp;&lt;i&gt;try&lt;/i&gt;&amp;nbsp;block raises an exception or not, the code in the&lt;i&gt;finally&lt;/i&gt;&amp;nbsp;block will be executed before control leaves the method.&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;Listing 15-2. Implementing a finally Block: FinallyDemo.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System.IO;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;FinallyDemo&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileStream outStream =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileStream inStream =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outStream = File.OpenWrite(&quot;DestinationFile.txt&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inStream = File.OpenRead(&quot;BogusInputFile.txt&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;(Exception ex)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(ex.ToString());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; finally&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(outStream !=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outStream.Close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;outStream closed.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(inStream !=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inStream.Close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;inStream closed.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
A finally block is not required and you may ask what happens if you just put code after the catch block. True, under normal circumstances, if the exception is caught, all code following the catch will be executed. However, try/catch/finally is for exceptional circumstances and it is better to plan for the worst to make your program more robust. For example, if one of the catch handlers rethrew an exception or caused another exception, the code following the catch block (not in a finally block) would never be executed. Also, if you don&#39;t catch the exception at all, program flow would immediately do a stack walk looking for an exception handler that fits and the code following the catch blocks would not be executed. Since there is too much potential for code in an algorithm to not be executed, a finally block is your insurance for executing those critical actions you need.&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/7090156741487258610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/exception-handling-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7090156741487258610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7090156741487258610'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/exception-handling-in-c.html' title='Exception Handling in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-6384890850015014934</id><published>2011-07-05T03:25:00.000-07:00</published><updated>2011-07-05T03:25:35.691-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Properties"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>Overview of Properties</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue;&quot;&gt;Overview of Properties&lt;/h4&gt;Properties provide the opportunity to protect a field in a class by reading and writing to it through the property. In other languages, this is often accomplished by programs implementing specialized getter and setter methods. C# properties enable this type of protection while also letting you access the property just like it was a field.&lt;br /&gt;
Another benefit of properties over fields is that you can change their internal implementation over time. With a public field, the underlying data type must always be the same because calling code depends on the field being the same. However, with a property, you&amp;nbsp; can change the implementation. For example, if a customer has an ID that is originally stored as an int, you might have a requirements change that made you perform a validation to ensure that calling code could never set the ID to a negative value. If it was a field, you would never be able to do this, but a property allows you to make such a change without breaking code. Now, lets see how to use properties.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue;&quot;&gt;Traditional Encapsultation Without Properties&lt;/h4&gt;Languages that don&#39;t have properties will use methods (functions or procedures) for encapsultation. The idea is to manage the values inside of the object, state, avoiding corruption and misuse by calling code.&lt;br /&gt;
&lt;h5 style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;An Example of Traditional Class Field Access&lt;/span&gt;&lt;/h5&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Customer
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; m_id = -1;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; GetID()
    {
        &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; m_id;
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; SetID(&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; id)
    {
        m_id = id;
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; m_name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; GetName()
    {
        &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; m_name;
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; SetName(&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; name)
    {
        m_name = name;
    }
}

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; CustomerManagerWithAccessorMethods
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Main()
    {
        Customer cust = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Customer();

        cust.SetID(1);
        cust.SetName(&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;Amelio Rosales&quot;&lt;/span&gt;);

        Console.WriteLine(
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;ID: {0}, Name: {1}&quot;&lt;/span&gt;,
            cust.GetID(),
            cust.GetName());

        Console.ReadKey();
    }
}&lt;/span&gt;&lt;/pre&gt;It shows the traditional method of accessing class fields. The&amp;nbsp;&lt;i&gt;Customer&lt;/i&gt;&amp;nbsp;class has four properties, two for each private field that the class encapsulates:&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;. As you can see,&amp;nbsp;&lt;i&gt;SetID&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;SetName&lt;/i&gt;&amp;nbsp;assign a new values and&amp;nbsp;&lt;i&gt;GetID&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;GetName&lt;/i&gt;&amp;nbsp;return values.&lt;br /&gt;
Observe how&amp;nbsp;&lt;i&gt;Main&lt;/i&gt;&amp;nbsp;calls the&amp;nbsp;&lt;i&gt;SetXxx&lt;/i&gt;&amp;nbsp;methods, which sets&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;to&amp;nbsp;&lt;i&gt;1&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;to &quot;Amelio Rosales&quot; in the&amp;nbsp;&lt;i&gt;Customer&lt;/i&gt;&amp;nbsp;instance,&amp;nbsp;&lt;i&gt;cust&lt;/i&gt;.&amp;nbsp; The call to&amp;nbsp;&lt;i&gt;Console.WriteLine&lt;/i&gt;&amp;nbsp;demonstrates how to read&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;from&amp;nbsp;&lt;i&gt;cust&lt;/i&gt;, via&amp;nbsp;&lt;i&gt;GetID&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;GetName&lt;/i&gt;&amp;nbsp;method calls, respectively.&lt;br /&gt;
This is such a common pattern, that C# has embraced it in the form of a language feature called properties, which you&#39;ll see in the next section.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue;&quot;&gt;Encapsulating Type State with Properties&lt;/h4&gt;The practice of accessing field data via methods was good because it supported the object-oriented concept of encapsulation. For example, if the type of&amp;nbsp;&lt;em&gt;m_id&lt;/em&gt;&amp;nbsp;or&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;changed from an&amp;nbsp;&lt;em&gt;int&lt;/em&gt;&amp;nbsp;type to&amp;nbsp;&lt;em&gt;byte&lt;/em&gt;, calling code would still work. Now the same thing can be accomplished in a much smoother fashion with properties.&lt;br /&gt;
&lt;h5 style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;Accessing Class Fields With Properties&lt;/span&gt;&lt;/h5&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Customer
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; m_id = -1;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ID
    {
        get
        {
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; m_id;
        }
        set
        {
            m_id = value;
        }
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; m_name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; Name
    {
        get
        {
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; m_name;
        }
        set
        {
            m_name = value;
        }
    }
}

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; CustomerManagerWithProperties
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Main()
    {
        Customer cust = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Customer();

        cust.ID = 1;
        cust.Name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;Amelio Rosales&quot;&lt;/span&gt;;

 Console.WriteLine(
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;ID: {0}, Name: {1}&quot;&lt;/span&gt;,
            cust.ID,
            cust.Name);

        Console.ReadKey();
    }
}&lt;/span&gt;&lt;/pre&gt;This program shows how to create and use a property. The&amp;nbsp;&lt;i&gt;Customer&lt;/i&gt;&amp;nbsp;class has the&amp;nbsp;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;property implementations. There are also private fields named&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name;&lt;/i&gt;&amp;nbsp;which&lt;i&gt;ID&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;, respectively, encapsulate. Each property has two accessors,&amp;nbsp;&lt;em&gt;get&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em&gt;set&lt;/em&gt;. The accessor returns the value of a field. The&amp;nbsp;&lt;i&gt;set&lt;/i&gt;&amp;nbsp;accessor sets the value of a field with the contents of&amp;nbsp;&lt;em&gt;value&lt;/em&gt;, which is the value being assigned by calling code. The&amp;nbsp;&lt;em&gt;value&lt;/em&gt;&amp;nbsp;shown in the accessor is a C# reserved word.&lt;br /&gt;
When setting a property, just assign a value to the property as if it were a field. The&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;CustomerManagerWithProperties&lt;/i&gt;&amp;nbsp;&lt;/span&gt;class uses the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;properties in the&amp;nbsp;&lt;em&gt;Customer&lt;/em&gt;&amp;nbsp;class. The first line of&amp;nbsp;&lt;em&gt;Main&lt;/em&gt;&amp;nbsp;instantiates a&amp;nbsp;&lt;i&gt;Customer&lt;/i&gt;&amp;nbsp;object named&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;. Next the value of the&amp;nbsp;&lt;em&gt;m_id&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;fields of&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;&amp;nbsp;are set by using the&amp;nbsp;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;properties.&lt;/span&gt;&lt;br /&gt;
To read from a property, use the property as if it were a field.&lt;em&gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Console.WriteLine&lt;/span&gt;&lt;/em&gt;&amp;nbsp;prints the value of the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;m_id&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;fields of&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;. It does this by calling the&amp;nbsp;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;properties of&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;.&lt;/span&gt;&lt;br /&gt;
This was a read/write property, but you can also create read-only properties, which you&#39;ll learn about next.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue;&quot;&gt;Creating Read-Only Properties&lt;/h4&gt;Properties can be made read-only. This is accomplished by having only a&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;get&lt;/em&gt;&amp;nbsp;&lt;/span&gt;accessor in the property implementation.&lt;br /&gt;
&lt;h5 style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;Read-Only Properties&lt;/span&gt;&lt;/h5&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Customer
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; m_id = -1;
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; m_name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; Customer(&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; id, &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; name)
    {
        m_id = id;
        m_name = name;
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ID
    {
        get
        {
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; m_id;
        }
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; Name
    {
        get
        {
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; m_name;
        }
    }
}

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; ReadOnlyCustomerManager
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Main()
    {
        Customer cust = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Customer(1, &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;Amelio Rosales&quot;&lt;/span&gt;);

        Console.WriteLine(
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;ID: {0}, Name: {1}&quot;&lt;/span&gt;,
            cust.ID,
            cust.Name);

        Console.ReadKey();
    }
}&lt;/span&gt;&lt;/pre&gt;The&amp;nbsp;&lt;i&gt;Customer&lt;/i&gt;&amp;nbsp;class in Listing &amp;nbsp;has two read-only properties,&amp;nbsp;&lt;i&gt;ID&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;. You can tell that each property is read-only because they only have&amp;nbsp;&lt;i&gt;get&lt;/i&gt;&amp;nbsp;accessors. At some time, values for the&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;must be assigned, which is the role of the constructor in this example.&lt;br /&gt;
The&amp;nbsp;&lt;em&gt;Main&lt;/em&gt;&amp;nbsp;method of the&amp;nbsp;&lt;em&gt;ReadOnlyCustomerManager&lt;/em&gt;&amp;nbsp;class instantiates a new&amp;nbsp;&lt;em&gt;Customer&lt;/em&gt;&amp;nbsp;object named&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;. The instantiation of&amp;nbsp;&lt;b&gt;&lt;em&gt;cust&lt;/em&gt;&amp;nbsp;uses the constructor of&amp;nbsp;&lt;em&gt;Customer&lt;/em&gt;&amp;nbsp;class, which takes&lt;em&gt;int&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;string&lt;/i&gt;&amp;nbsp;type parameters. In this case, the values are&amp;nbsp;&lt;i&gt;1&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;&quot;Amelio Rosales&quot;&lt;/i&gt;. This initializes the&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;fields of&amp;nbsp;&lt;i&gt;cust&lt;/i&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Since the&amp;nbsp;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;properties of the&amp;nbsp;&lt;em&gt;Customer&lt;/em&gt;&lt;/b&gt;&amp;nbsp;class are read-only, there is no other way to set the value of the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;m_id&lt;/em&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;&lt;/span&gt;fields. If you inserted&amp;nbsp;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;cust&lt;/span&gt;.&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;ID =&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;7&lt;/span&gt;&lt;/em&gt;&amp;nbsp;into the listing, the program would not compile, because&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;&lt;/span&gt;is read-only; the same goes for&amp;nbsp;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Name&lt;/span&gt;&lt;/i&gt;. When the&amp;nbsp;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;ID&lt;/span&gt;&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;&lt;/span&gt;properties are used in&amp;nbsp;&lt;em&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Console&lt;/span&gt;.&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;WriteLine&lt;/span&gt;&lt;/em&gt;, they work fine. This is because these are read operations which only invoke the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;get&lt;/em&gt;&amp;nbsp;&lt;/span&gt;accessor of the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;&lt;/span&gt;properties.&lt;br /&gt;
One question you might have now is &quot;If a property can be read-only, can it also be write-only?&quot; The answer is yes, and explained in the next section.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue;&quot;&gt;Creating a Write-Only Property&lt;/h4&gt;You can assign values to, but not read from, a write-only property. A write-only property only has a&amp;nbsp;&lt;i&gt;set&lt;/i&gt;&amp;nbsp;accessor.&lt;br /&gt;
&lt;h5 style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;Write-Only Properties&lt;/span&gt;&lt;/h5&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Customer
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; m_id = -1;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ID
    {
        set
        {
            m_id = value;
        }
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; m_name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty;

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; Name
    {
        set
        {
            m_name = value;
        }
    }

    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; DisplayCustomerData()
    {
        Console.WriteLine(&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;ID: {0}, Name: {1}&quot;&lt;/span&gt;, m_id, m_name);
    }
}

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; WriteOnlyCustomerManager
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Main()
    {
        Customer cust = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Customer();

        cust.ID = 1;
        cust.Name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;Amelio Rosales&quot;&lt;/span&gt;;

        cust.DisplayCustomerData();

        Console.ReadKey();
    }
}&lt;/span&gt;&lt;/pre&gt;This time, the&amp;nbsp;&lt;em&gt;get&lt;/em&gt;&amp;nbsp;accessor is removed from the&amp;nbsp;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;properties of the&amp;nbsp;&lt;em&gt;Customer&lt;/em&gt;&amp;nbsp;class. The&amp;nbsp;&lt;em&gt;set&lt;/em&gt;&amp;nbsp;accessors have been added, assigning&amp;nbsp;&lt;i&gt;value&lt;/i&gt;&amp;nbsp;to the backing store fields,&amp;nbsp;&lt;i&gt;m_id&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;.&lt;br /&gt;
The&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;Main&lt;/em&gt;&amp;nbsp;&lt;/span&gt;method of the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;WriteOnlyCustomerManager&lt;/i&gt;&amp;nbsp;&lt;/span&gt;class instantiates the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;Customer&lt;/em&gt;&amp;nbsp;&lt;/span&gt;class with a default constructor. Then it uses the&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;ID&lt;/em&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;&lt;/span&gt;properties of&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;em&gt;cust&lt;/em&gt;&amp;nbsp;to set the&amp;nbsp;&lt;em&gt;m_id&lt;/em&gt;and&amp;nbsp;&lt;i&gt;m_name&lt;/i&gt;&amp;nbsp;fields of&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;&amp;nbsp;to&amp;nbsp;&lt;i&gt;1&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;&quot;Amelio Rosales&quot;&lt;/i&gt;, respectively. This invokes the&amp;nbsp;&lt;em&gt;set&lt;/em&gt;&amp;nbsp;accessor of&amp;nbsp;&lt;i&gt;ID&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;properties from the&amp;nbsp;&lt;em&gt;cust&lt;/em&gt;&amp;nbsp;instance.&lt;/span&gt;&lt;br /&gt;
When you have a lot of properties in a class or struct, there can also be a lot of code associated with those properties. In the next section, you&#39;ll see how to write properties with less code.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue;&quot;&gt;Creating Auto-Implemented Properties&lt;/h4&gt;The patterns you see here, where a property encapsulates a property with&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;get&lt;/i&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;set&lt;/i&gt;&amp;nbsp;&lt;/span&gt;accessors, without any other logic is common. It is more code than we should have to write for such a common scenario. That&#39;s why C# 3.0 introduced a new syntax for a property, called an&amp;nbsp;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;auto&lt;/span&gt;-&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;implemented property&lt;/span&gt;&lt;/i&gt;, which allows you to create properties without&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;get&lt;/i&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;i&gt;set&lt;/i&gt;accessor&lt;/span&gt; implementations.&lt;br /&gt;
&lt;h5 style=&quot;color: grey;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&amp;nbsp;Auto-Impemented Properties&lt;/span&gt;&lt;/h5&gt;&lt;pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;using&lt;/span&gt; System;

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; Customer
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ID { get; set; }
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; Name { get; set; }
}

&lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;class&lt;/span&gt; AutoImplementedCustomerManager
{
    &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;static&lt;/span&gt; &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; Main()
    {
        Customer cust = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Customer();

        cust.ID = 1;
        cust.Name = &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;Amelio Rosales&quot;&lt;/span&gt;;

        Console.WriteLine(
            &lt;span family=&quot;Microsoft Sans Serif&quot; style=&quot;color: red;&quot;&gt;&quot;ID: {0}, Name: {1}&quot;&lt;/span&gt;,
            cust.ID,
            cust.Name);

        Console.ReadKey();
    }
}&lt;/span&gt;&lt;/pre&gt;&lt;div style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/6384890850015014934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/overview-of-properties.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/6384890850015014934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/6384890850015014934'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/overview-of-properties.html' title='Overview of Properties'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-9081997856245957193</id><published>2011-07-05T03:14:00.000-07:00</published><updated>2011-07-05T03:18:03.616-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Interfaces"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How can use interfaces in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;color: navy; font-size: 17px;&quot;&gt;Interfaces&lt;/h3&gt;&lt;br /&gt;
An&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;looks like a class, but has no implementation. The only thing it contains are definitions of&amp;nbsp;&lt;i&gt;events&lt;/i&gt;,&amp;nbsp;&lt;i&gt;indexers&lt;/i&gt;,&amp;nbsp;&lt;i&gt;methods&lt;/i&gt;&amp;nbsp;and/or&amp;nbsp;&lt;i&gt;properties&lt;/i&gt;. The reason&amp;nbsp;&lt;i&gt;interfaces&lt;/i&gt;&amp;nbsp;only provide definitions is because they are inherited by&amp;nbsp;&lt;i&gt;classes&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;structs&lt;/i&gt;, which must provide an implementation for each interface member defined.&lt;br /&gt;
So, what are&amp;nbsp;&lt;i&gt;interfaces&lt;/i&gt;&amp;nbsp;good for if they don&#39;t implement functionality? They&#39;re great for putting together plug-n-play like architectures where components can be interchanged at will. Since all interchangeable components implement the same&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;, they can be used without any extra programming. The&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;forces each component to expose specific public members that will be used in a certain way.&lt;br /&gt;
Because&amp;nbsp;&lt;i&gt;interfaces&lt;/i&gt;&amp;nbsp;must be implemented by derived&amp;nbsp;&lt;i&gt;classes&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;structs&lt;/i&gt;, they define a contract. For instance, if class&amp;nbsp;&lt;i&gt;foo&lt;/i&gt;&amp;nbsp;implements the&amp;nbsp;&lt;i&gt;IDisposable&lt;/i&gt;&amp;nbsp;interface, it is making a statement that it guarantees it has the&amp;nbsp;&lt;i&gt;Dispose()&lt;/i&gt;&amp;nbsp;method, which is the only member of the&amp;nbsp;&lt;i&gt;IDisposable&lt;/i&gt;&amp;nbsp;interface. Any code that wishes to use class&amp;nbsp;&lt;i&gt;foo&lt;/i&gt;&amp;nbsp;may check to see if class&amp;nbsp;&lt;i&gt;foo&lt;/i&gt;&amp;nbsp;implements&lt;i&gt;IDisposable&lt;/i&gt;. When the answer is&amp;nbsp;&lt;i&gt;true&lt;/i&gt;, then the code knows that it can call&amp;nbsp;&lt;i&gt;foo.Dispose()&lt;/i&gt;. Listing 13-1 shows how to define an interface:&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;&amp;nbsp;Defining an Interface: MyInterface.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;interface&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;IMyInterface&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MethodToImplement();&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
It defines an&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;named&amp;nbsp;&lt;i&gt;IMyInterface&lt;/i&gt;. A common naming convention is to prefix all&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;names with a capital &quot;I&quot;. This&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;has a single method named&lt;i&gt;MethodToImplement()&lt;/i&gt;. This could have been any type of method declaration with different parameters and return types. I just chose to declare this method with no parameters and a&lt;i&gt;void&lt;/i&gt;&amp;nbsp;return type to make the example easy. Notice that this method does not have an implementation (instructions between curly braces -&amp;nbsp;&lt;i&gt;{}&lt;/i&gt;), but instead ends with a semi-colon, &quot;&lt;i&gt;;&lt;/i&gt;&quot;. This is because the&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;only specifies the signature of methods that an inheriting&amp;nbsp;&lt;i&gt;class&lt;/i&gt;&amp;nbsp;or&amp;nbsp;&lt;i&gt;struct&lt;/i&gt;&amp;nbsp;must implement. Listing 13-2 shows how this&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;could be used.&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;&amp;nbsp;Using an Interface: InterfaceImplementer.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;InterfaceImplementer : IMyInterface&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InterfaceImplementer iImp =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;InterfaceImplementer();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iImp.MethodToImplement();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MethodToImplement()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;MethodToImplement() called.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;InterfaceImplementer&lt;/i&gt;&amp;nbsp;&lt;i&gt;class&lt;/i&gt;&amp;nbsp;implements the&amp;nbsp;&lt;i&gt;IMyInterface&lt;/i&gt;&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;. Indicating that a&amp;nbsp;&lt;i&gt;class&lt;/i&gt;&amp;nbsp;inherits an&amp;nbsp;&lt;i&gt;interface&lt;/i&gt;&amp;nbsp;is the same as inheriting a&amp;nbsp;&lt;i&gt;class&lt;/i&gt;. In this case, the following syntax is used:&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;InterfaceImplementer : IMyInterface&lt;/span&gt;&lt;br /&gt;
Now that this&amp;nbsp;&lt;i&gt;class&lt;/i&gt;&amp;nbsp;inherits the&amp;nbsp;&lt;i&gt;IMyInterface&amp;nbsp;&lt;/i&gt;interface, it must implement its members. It does this by implementing the&amp;nbsp;&lt;i&gt;MethodToImplement()&amp;nbsp;&lt;/i&gt;method. Notice that this method implementation has the exact same signature, parameters and method name, as defined in the&amp;nbsp;&lt;i&gt;IMyInterface&lt;/i&gt;&amp;nbsp;interface. Any difference between the method signature in the interface and the method signature in the implementing&amp;nbsp;&lt;i&gt;class&lt;/i&gt;&amp;nbsp;or&amp;nbsp;&lt;i&gt;struct&lt;/i&gt;&amp;nbsp;will cause a compiler error. Additionally, a&amp;nbsp;&lt;i&gt;class&lt;/i&gt;&amp;nbsp;or&amp;nbsp;&lt;i&gt;struct&lt;/i&gt;&amp;nbsp;that inherits an interface must include all interface members; You will receive a compiler error if you don&#39;t implement all interface members.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: grey; font-family: Verdana, Geneva, Arial, sans-serif; font-size: 12px; font-weight: bold;&quot;&gt;&amp;nbsp;Inheritance: InterfaceInheritance.cs&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;interface&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;IParentInterface&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;ParentInterfaceMethod();&lt;br /&gt;
}&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
interface&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;IMyInterface : IParentInterface&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MethodToImplement();&lt;br /&gt;
}&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;InterfaceImplementer : IMyInterface&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InterfaceImplementer iImp =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;InterfaceImplementer();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iImp.MethodToImplement();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iImp.ParentInterfaceMethod();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MethodToImplement()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;MethodToImplement() called.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;ParentInterfaceMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;ParentInterfaceMethod() called.&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/9081997856245957193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/how-can-use-interfaces-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/9081997856245957193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/9081997856245957193'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/how-can-use-interfaces-in-c.html' title='How can use interfaces in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-7189796710921427883</id><published>2011-07-05T03:10:00.000-07:00</published><updated>2011-07-05T03:15:13.900-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Events and Delegates"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How can use Delegates and Events</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;color: navy; font-size: 17px;&quot;&gt;Introduction to Delegates and Events&lt;/h3&gt;&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Delegates&lt;/h4&gt;During previous lessons, you learned how to implement reference types using language constructs such as classes and interfaces. These reference types allowed you to create instances of objects and use them in special ways to accomplish your software development goals. Classes allow you to create objects that contained members with attributes or behavior. Interfaces allow you to declare a set of attributes and behavior that all objects implementing them would publicly expose. Today, I&#39;m going to introduce a new reference type called a&lt;i&gt;delegate&lt;/i&gt;.&lt;br /&gt;
A&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;is a C# language element that allows you to reference a method. If you were a C or C++ programmer, this would sound familiar because a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;is basically a function pointer. However, developers who have used other languages are probably wondering, &quot;Why do I need a reference to a method?&quot;. The answer boils down to giving you maximum flexibility to implement any functionality you want at runtime.&lt;br /&gt;
Think about how you use methods right now. You write an algorithm that does its thing by manipulating the values of variables and calling methods directly by name. What if you wanted an algorithm that was very flexible, reusable, and allowed you to implement different functionality as the need arises? Furthermore, let&#39;s say that this was an algorithm that supported some type of data structure that you wanted to have sorted, but you also want to enable this data structure to hold different types. If you don&#39;t know what the types are, how could you decide an appropriate comparison routine?&amp;nbsp; Perhaps you could implement an&amp;nbsp;&lt;i&gt;if/then/else&lt;/i&gt;&amp;nbsp;or&amp;nbsp;&lt;i&gt;switch&lt;/i&gt;&amp;nbsp;statement to handle well-known types, but this would still be limiting and require overhead to determine the type. Another alternative would be for all the types to implement an interface that declared a common method your algorithm would call, which is actually a nice solution. However, since this lesson is about&amp;nbsp;&lt;i&gt;delegates&lt;/i&gt;, we&#39;ll apply a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;solution, which is quite elegant.&lt;br /&gt;
You could solve this problem by passing a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;to your algorithm and letting the contained method, which the&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;refers to, perform the comparison operation. Such an operation is performed in Listing .&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;&amp;nbsp;Declaring and Implementing a Delegate: SimpleDelegate.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;// this is the delegate declaration&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;delegate&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Comparer(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;obj1,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;obj2);&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;FirstName =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;LastName =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;first,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;last)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FirstName = first;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LastName = last;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;// this is the delegate method handler&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;CompareFirstNames(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;name1,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;name2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;n1 = ((Name)name1).FirstName;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;n2 = ((Name)name2).FirstName;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(String.Compare(n1, n2) &amp;gt; 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(String.Compare(n1, n2) &amp;lt; 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;-1;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;0;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;ToString()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;FirstName + &quot; &quot; + LastName;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;SimpleDelegate&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Name[] names =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name[5];&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;SimpleDelegate()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[0] =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name(&quot;Joe&quot;, &quot;Mayo&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[1] =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name(&quot;John&quot;, &quot;Hancock&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[2] =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name(&quot;Jane&quot;, &quot;Doe&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[3] =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name(&quot;John&quot;, &quot;Doe&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[4] =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Name(&quot;Jack&quot;, &quot;Smith&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SimpleDelegate sd =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;SimpleDelegate();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;// this is the delegate instantiation&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Comparer cmp =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Comparer(Name.CompareFirstNames);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;\nBefore Sort: \n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sd.PrintNames();&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // observe the delegate argument&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sd.Sort(cmp);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;\nAfter Sort: \n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sd.PrintNames();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // observe&amp;nbsp; the delegate parameter&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Sort(Comparer compare)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;temp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;i=0; i &amp;lt; names.Length; i++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;j=i; j &amp;lt; names.Length; j++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // using delegate &quot;compare&quot; just like&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // a normal method&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;( compare(names[i], names[j]) &amp;gt; 0 )&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp = names[i];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[i] = names[j];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; names[j] = (Name)temp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;PrintNames()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;Names: \n&quot;);&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;(Name name&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;names)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(name.ToString());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
The first thing the program in Listing 14-1 does is declare a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;.&amp;nbsp;&lt;i&gt;Delegate&lt;/i&gt;&amp;nbsp;declarations look somewhat like methods, except they have the&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;modifier, are terminated with a semi-colon (&lt;i&gt;;&lt;/i&gt;), and have no implementation. Below, is the&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;declaration from Listing 14-1.&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;delegate&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Comparer(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;obj1,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;obj2);&lt;/span&gt;&lt;br /&gt;
This&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;declaration defines the signature of a delegate handler method that this&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;can refer to. The delegate handler method, for the&amp;nbsp;&lt;i&gt;Comparer&lt;/i&gt;&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;, can have any name, but must have a first parameter of type&amp;nbsp;&lt;i&gt;object&lt;/i&gt;, a second parameter of type&amp;nbsp;&lt;i&gt;object&lt;/i&gt;, and return an&amp;nbsp;&lt;i&gt;int&lt;/i&gt;&amp;nbsp;type. The following method from &amp;nbsp;shows a delegate handler method that conforms to the signature of the&amp;nbsp;&lt;i&gt;Comparer&lt;/i&gt;&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;.&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;CompareFirstNames(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;name1,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;name2)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;The&amp;nbsp;&lt;i&gt;CompareFirstNames&lt;/i&gt;&amp;nbsp;method calls&amp;nbsp;&lt;i&gt;String.Compare&lt;/i&gt;&amp;nbsp;to compare the&amp;nbsp;&lt;i&gt;FirstName&lt;/i&gt;&amp;nbsp;properties of the two&amp;nbsp;&lt;i&gt;Name&lt;/i&gt;&amp;nbsp;instances. The&amp;nbsp;&lt;i&gt;String&lt;/i&gt;&amp;nbsp;class has many convenience methods, such as&lt;i&gt;Compare&lt;/i&gt;, for working with strings. Please don&#39;t allow the implementation of this method to interfere with learning how delegates work. What you should concentrate on is that&lt;i&gt;CompareFirstNames&lt;/i&gt;&amp;nbsp;is a handler method that a delegate can refer to, regardless of the code inside of that method.&lt;br /&gt;
To use a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;, you must create an instance of it. The instance is created, similar to a class instance, with a single parameter identifying the appropriate delegate handler method, as shown below.&lt;br /&gt;
&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Comparer cmp =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Comparer(Name.CompareFirstNames);&lt;/span&gt;&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;,&amp;nbsp;&lt;i&gt;cmp&lt;/i&gt;, is then used as a parameter to the&amp;nbsp;&lt;i&gt;Sort()&lt;/i&gt;&amp;nbsp;method, which uses it just like a normal method. Observe the way the&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;is passed to the&amp;nbsp;&lt;i&gt;Sort()&amp;nbsp;&lt;/i&gt;method as a parameter in the code below.&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sd.Sort(cmp);&lt;/span&gt;&lt;br /&gt;
Using this technique, any delegate handler method may be passed to the&amp;nbsp;&lt;i&gt;Sort()&amp;nbsp;&lt;/i&gt;method at run-time. i.e. You could define a method handler named&amp;nbsp;&lt;i&gt;CompareLastNames()&lt;/i&gt;, instantiate a new&amp;nbsp;&lt;i&gt;Comparer delegate&lt;/i&gt;&amp;nbsp;instance with it, and pass the new&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;to the&amp;nbsp;&lt;i&gt;Sort()&lt;/i&gt;&amp;nbsp;method.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Events&lt;/h4&gt;Traditional Console applications operate by waiting for a user to press a key or type a command and press the&amp;nbsp;&lt;i&gt;Enter&lt;/i&gt;&amp;nbsp;key. Then they perform some pre-defined operation and either quit or return to the original prompt that they started from. This works, but is inflexible in that everything is hard-wired and follows a rigid path of execution. In stark contrast, modern GUI programs operate on an event-based model. That is, some event in the system occurs and interested modules are notified so they can react appropriately. With Windows Forms, there is not a polling mechanism taking up resources and you don&#39;t have to code a loop that sits waiting for input. It is all built into the system with events.&lt;br /&gt;
A C#&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;is a class member that is activated whenever the event it was designed for occurs. I like to use the term &quot;fires&quot; when the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;is activated. Anyone interested in the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;can register and be notified as soon as the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;fires. At the time an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;fires, registered methods will be invoked.&lt;br /&gt;
&lt;i&gt;Events&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;delegates&lt;/i&gt;&amp;nbsp;work hand-in-hand to provide a program&#39;s functionality. It starts with a class that declares an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;. Any class, including the same class that the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;is declared in, may register one of its methods for the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;. This occurs through a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;, which specifies the signature of the method that is registered for the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;. The&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;may be one of the pre-defined .NET&amp;nbsp;&lt;i&gt;delegates&lt;/i&gt;&amp;nbsp;or one you declare yourself. Whichever is appropriate, you assign the&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;to the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;, which effectively registers the method that will be called when the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;fires. Listing 14-2 shows a couple different ways to implement&amp;nbsp;&lt;i&gt;events&lt;/i&gt;.&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;Listing 14-2. Declaring and Implementing Events: Eventdemo.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System.Drawing;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System.Windows.Forms;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;// custom delegate&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;delegate&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Startdelegate();&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Eventdemo : Form&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // custom event&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Startdelegate StartEvent;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Eventdemo()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Button clickMe =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Button();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickMe.Parent =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickMe.Text = &quot;Click Me&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickMe.Location =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Point(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (ClientSize.Width - clickMe.Width) /2,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (ClientSize.Height - clickMe.Height)/2);&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // an EventHandler delegate is assigned&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // to the button&#39;s Click event&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickMe.Click +=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;EventHandler(OnClickMeClicked);&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // our custom &quot;Startdelegate&quot; delegate is assigned&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // to our custom &quot;StartEvent&quot; event.&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StartEvent +=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Startdelegate(OnStartEvent);&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // fire our custom event&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StartEvent();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // this method is called when the &quot;clickMe&quot; button is pressed&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;OnClickMeClicked(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;sender, EventArgs ea)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(&quot;You Clicked My Button!&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // this method is called when the &quot;StartEvent&quot; Event is fired&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;OnStartEvent()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(&quot;I Just Started!&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Application.Run(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Eventdemo());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt;&amp;nbsp;If you&#39;re using Visual Studio or another IDE, remember to add references to System.Drawing.dll and System.Windows.Forms.dll before compiling or just add the code to a Windows Forms project. Teaching the operation of Visual Studio or other IDE&#39;s is out-of-scope for this tutorial.&lt;br /&gt;
You may have noticed that Listing 14-2 is a Windows Forms program. Although I haven&#39;t covered Windows Forms in this tutorial, you should know enough about C# programming in general that you won&#39;t be lost. To help out, I&#39;ll give a brief explanation of some of the parts that you may not be familiar with.&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;Eventdemo&lt;/i&gt;&amp;nbsp;class inherits&amp;nbsp;&lt;i&gt;Form&lt;/i&gt;, which essentially makes it a Windows Form. This automatically gives you all the functionality of a Windows Form, including Title Bar, Minimize/Maximize/Close buttons, System Menu, and Borders. A lot of power, that inheritance thing, eh?&lt;br /&gt;
The way a Windows Form&#39;s application is started is by calling the&amp;nbsp;&lt;i&gt;Run()&lt;/i&gt;&amp;nbsp;method of the&amp;nbsp;&lt;i&gt;static&lt;/i&gt;&amp;nbsp;&lt;i&gt;Application&lt;/i&gt;&amp;nbsp;object with a reference to the&amp;nbsp;&lt;i&gt;form&lt;/i&gt;&amp;nbsp;object as its parameter. This starts up all the underlying Windows plumbing, displays the GUI, and ensures that&amp;nbsp;&lt;i&gt;events&lt;/i&gt;&amp;nbsp;are fired as appropriate.&lt;br /&gt;
Let&#39;s look at the custom&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;first. Below is the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;declaration, which is a member of the&amp;nbsp;&lt;i&gt;Eventdemo&lt;/i&gt;&amp;nbsp;class. It is declared with the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;keyword, a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;type, and an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;name.&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Startdelegate StartEvent;&lt;/span&gt;&lt;br /&gt;
Anyone interested in an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;can register by hooking up a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;for that&amp;nbsp;&lt;i&gt;event&lt;/i&gt;. On the next line, we have a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;of type&amp;nbsp;&lt;i&gt;Startdelegate&lt;/i&gt;, which the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;was declared to accept, hooked up to the&amp;nbsp;&lt;i&gt;StartEvent&lt;/i&gt;&amp;nbsp;&lt;i&gt;event&lt;/i&gt;. The&amp;nbsp;&lt;i&gt;+=&lt;/i&gt;&amp;nbsp;syntax registers a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;with an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;. To unregister with an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;, use the&amp;nbsp;&lt;i&gt;-=&lt;/i&gt;&amp;nbsp;with the same syntax.&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StartEvent +=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Startdelegate(OnStartEvent);&lt;/span&gt;&lt;br /&gt;
Firing an&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;looks just like a method call, as shown below:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;StartEvent();&lt;/span&gt;&lt;br /&gt;
This was how to implement&amp;nbsp;&lt;i&gt;events&lt;/i&gt;&amp;nbsp;from scratch, declaring the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;yourself. However, much of the&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;programming you&#39;ll do will be with pre-defined&amp;nbsp;&lt;i&gt;events&lt;/i&gt;&amp;nbsp;and&lt;i&gt;delegates&lt;/i&gt;. This leads us to the other&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;code you see in Listing 14-2, where we hook up an&amp;nbsp;&lt;i&gt;EventHandler&lt;/i&gt;&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;to a&amp;nbsp;&lt;i&gt;Button&lt;/i&gt;&amp;nbsp;&lt;i&gt;Click&lt;/i&gt;&amp;nbsp;event.&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clickMe.Click +=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;EventHandler(OnClickMeClicked);&lt;/span&gt;&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;Click&lt;/i&gt;&amp;nbsp;event already belongs to the&amp;nbsp;&lt;i&gt;Button&lt;/i&gt;&amp;nbsp;class and all we have to do is reference it when registering a&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;. Similarly, the&amp;nbsp;&lt;i&gt;EventHandler&lt;/i&gt;&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;&amp;nbsp;already exists in the&amp;nbsp;&lt;i&gt;System&lt;/i&gt;namespace of the .NET Frameworks Class Library. All you really need to do is define your callback method (delegate handler method) that is invoked when someone presses the&amp;nbsp;&lt;i&gt;clickMe&lt;/i&gt;button. The&amp;nbsp;&lt;i&gt;OnClickMeClicked()&lt;/i&gt;&amp;nbsp;method, shown below, conforms to the signature of the&amp;nbsp;&lt;i&gt;EventHander&lt;/i&gt;&amp;nbsp;&lt;i&gt;delegate&lt;/i&gt;, which you can look up in the .NET Framework Class Library reference.&lt;br /&gt;
&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;OnClickMeClicked(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;sender, EventArgs ea)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(&quot;You Clicked My Button!&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
Any time the&amp;nbsp;&lt;i&gt;clickMe&lt;/i&gt;&amp;nbsp;button is pressed with a mouse, it will fire the&amp;nbsp;&lt;i&gt;Click&lt;/i&gt;&amp;nbsp;&lt;i&gt;event&lt;/i&gt;, which will invoke the&amp;nbsp;&lt;i&gt;OnClickMeClicked()&lt;/i&gt;&amp;nbsp;method. The&amp;nbsp;&lt;i&gt;Button&lt;/i&gt;&amp;nbsp;class takes care of firing the&amp;nbsp;&lt;i&gt;Click&lt;/i&gt;&amp;nbsp;&lt;i&gt;event&lt;/i&gt;&amp;nbsp;and there&#39;s nothing more you have to do. Because it is so easy to use pre-defined&amp;nbsp;&lt;i&gt;events&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i&gt;delegates&lt;/i&gt;, it would be a good idea to check if some exist already that will do what you need, before creating your own.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/7189796710921427883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/how-can-use-delegates-and-events.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7189796710921427883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7189796710921427883'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/how-can-use-delegates-and-events.html' title='How can use Delegates and Events'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-4571478914235237325</id><published>2011-07-05T03:09:00.000-07:00</published><updated>2011-07-05T03:16:24.420-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Attributes"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How can use attributes in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, sans-serif; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;color: navy; font-size: 17px;&quot;&gt;&amp;nbsp;Using Attributes&lt;/h3&gt;&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Why Attributes?&lt;/h4&gt;Attributes are elements that allow you to add declarative information to your programs. This declarative information is used for various purposes during runtime and can be used at design time by application development tools. For example, there are attributes such as DllImportAttribute that allow a program to communicate with the Win32 libraries. Another attribute, ObsoleteAttribute, causes a compile-time warning to appear, letting the developer know that a method should no longer be used. When building Windows forms applications, there are several attributes that allow visual components to be drag-n-dropped onto a visual form builder and have their information appear in the properties grid. Attributes are also used extensively in securing .NET assemblies, forcing calling code to be evaluated against pre-defined security constraints. These are just a few descriptions of how attributes are used in C# programs.&lt;br /&gt;
The reason attributes are necessary is because many of the services they provide would be very difficult to accomplish with normal code. You see, attributes add what is called metadata to your programs. When your C# program is compiled, it creates a file called an assembly, which is normally an executable or DLL library. Assemblies are self-describing because they have metadata written to them when they are compiled. Via a process known as reflection, a program&#39;s attributes can be retrieved from its assembly metadata. Attributes are classes that can be written in C# and used to decorate your code with declarative information. This is a very powerful concept because it means that you can extend your language by creating customized declarative syntax with attributes.&lt;br /&gt;
This tutorial will show how to use pre-existing attributes in C# programs. Understanding the concepts and how to use a few attributes, will help in finding the multitude of other pre-existing attributes in the .NET class libraries and use them also.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Attribute Basics&lt;/h4&gt;Attributes are generally applied physically in front of type and type member declarations. They&#39;re declared with square brackets, &quot;[&quot; and &quot;]&quot;, surrounding the attribute such as the following&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute:&lt;br /&gt;
&lt;pre style=&quot;font-size: 10px;&quot;&gt;[ObsoleteAttribute]&lt;/pre&gt;The &quot;Attribute&quot; part of the attribute name is optional. So the following is equivalent to the attribute above:&lt;br /&gt;
&lt;pre style=&quot;font-size: 10px;&quot;&gt;[Obsolete]&lt;/pre&gt;You&#39;ll notice that the attribute is declared with only the name of the attribute, surrounded by square brackets. Many attributes have parameter lists, that allow inclusion of additional information that customizes a program even further.&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;&amp;nbsp;How to Use Attributes: BasicAttributeDemo.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;BasicAttributeDemo&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [Obsolete]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MyFirstdeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;Called MyFirstdeprecatedMethod().&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [ObsoleteAttribute]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MySecondDeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;Called MySecondDeprecatedMethod().&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [Obsolete(&quot;You shouldn&#39;t use this method anymore.&quot;)]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MyThirdDeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;Called MyThirdDeprecatedMethod().&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: green; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // make the program thread safe for COM&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [STAThread]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BasicAttributeDemo attrDemo =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;BasicAttributeDemo();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrDemo.MyFirstdeprecatedMethod();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrDemo.MySecondDeprecatedMethod();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attrDemo.MyThirdDeprecatedMethod();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
Examining the code in listing 16-1 reveals that the&amp;nbsp;&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute was used a few different ways. The first usage appeared on the&amp;nbsp;&lt;i&gt;MyFirstdeprecatedMethod()&lt;/i&gt;&amp;nbsp;method and the second usage appeared in the&amp;nbsp;&lt;i&gt;MySecondDeprecatedMethod()&lt;/i&gt;&amp;nbsp;method as follows:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Obsolete]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MyFirstdeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [ObsoleteAttribute]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MySecondDeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
The only difference between the two attributes is that&amp;nbsp;&lt;i&gt;MySecondDeprecatedMethod()&lt;/i&gt;&amp;nbsp;method contains the &quot;Attribute&quot; in the attribute declaration. The results of both attributes are exactly the same. Attributes may also have parameters, as shown in the following declaration:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Obsolete(&quot;You shouldn&#39;t use this method anymore.&quot;)]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MyThirdDeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
This adds customized behavior to the&amp;nbsp;&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute which produces different results from the other&amp;nbsp;&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute declarations. The results of all three&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attributes are shown below. These are the warnings that are emitted by the C# compiler when the program is compiled:&lt;br /&gt;
&lt;pre style=&quot;font-size: 10px;&quot;&gt;&amp;gt;csc BasicAttributeDemo.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.2292.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

BasicAttributeDemo.cs(29,3): warning CS0612:
&#39;BasicAttributeDemo.MyFirstdeprecatedMethod()&#39; is obsolete
BasicAttributeDemo.cs(30,3): warning CS0612:
&#39;BasicAttributeDemo.MySecondDeprecatedMethod()&#39; is obsolete
BasicAttributeDemo.cs(31,3): warning CS0618:
&#39;BasicAttributeDemo.MyThirdDeprecatedMethod()&#39; is obsolete: &#39;You
shouldn&#39;t use this method anymore.&#39; &lt;/pre&gt;As you can see, the&amp;nbsp;&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute caused the&amp;nbsp;&lt;i&gt;MyThirdDeprecatedMethod()&lt;/i&gt;&amp;nbsp;method to emit the message that was a parameter to the&amp;nbsp;&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute of that method in the code. The other attributes simply emitted standard warnings.&lt;br /&gt;
It also contains another attribute you&#39;re likely to see, the&amp;nbsp;&lt;i&gt;STAThreadAttribute&lt;/i&gt;&amp;nbsp;attribute. You&#39;ll often see this attribute applied to the&amp;nbsp;&lt;i&gt;Main()&lt;/i&gt;&amp;nbsp;method, indicating that this C# program should communicate with unmanaged COM code using the Single Threading Apartment . It is generally safe to use this attribute all the time because you never know when a 3rd party library you&#39;re using is going to be communicating with COM. The following excerpt shows how to use the&amp;nbsp;&lt;i&gt;STAThreadAttribute&lt;/i&gt;&amp;nbsp;attribute:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [STAThread]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Attribute Parameters&lt;/h4&gt;Attributes often have parameters that enable customization. There are two types of parameters that can be used on attributes, positional and named. Positional parameters are used when the attribute creator wishes the parameters to be required. However, this is not a hard and fast rule because the&amp;nbsp;&lt;i&gt;ObsoleteAttribute&lt;/i&gt;&amp;nbsp;attribute has a second positional parameter named error of type&amp;nbsp;&lt;i&gt;bool&lt;/i&gt;&amp;nbsp;that we can omit as demonstrated . That attribute could have been written with the second positional parameter to force a compiler error instead of just a warning as follows:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Obsolete(&quot;You shouldn&#39;t use this method anymore.&quot;,&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;)]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MyThirdDeprecatedMethod()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/span&gt;&lt;br /&gt;
The difference between positional parameters and named parameters are that named parameters are specified with the name of the parameter and are always optional. The&lt;i&gt;DllImportAttribute&lt;/i&gt;&amp;nbsp;attribute is one you are likely to see that has both positional and named attributes (Listing 16-2).&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;Listing 16-2. Using Positional and Named Attribute Parameters: AttributeParamsDemo.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System.Runtime.InteropServices;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;AttributeParamsDemo&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [DllImport(&quot;User32.dll&quot;, EntryPoint=&quot;MessageBox&quot;)]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;extern&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;MessageDialog(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;hWnd,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;msg,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;caption,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;msgType);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [STAThread]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageDialog(0, &quot;MessageDialog Called!&quot;, &quot;DllImport Demo&quot;, 0);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
The&amp;nbsp;&lt;i&gt;DllImportAttribute&lt;/i&gt;&amp;nbsp;attribute &amp;nbsp;has one positional parameter,&amp;nbsp;&lt;i&gt;&quot;User32.dll&quot;&lt;/i&gt;, and one named parameter,&amp;nbsp;&lt;i&gt;EntryPoint=&quot;MessageBox&quot;&lt;/i&gt;. Positional parameters are always specified before any named parameters. When there are named parameters, they may appear in any order. This is because they are marked with the parameter name like in the&amp;nbsp;&lt;i&gt;DllImportAttribute&lt;/i&gt;attribute,&amp;nbsp;&lt;i&gt;EntryPoint=&quot;MessageBox&quot;&lt;/i&gt;. Since the purpose of this lesson is to explain how to use attributes in general, I won&#39;t go into the details of the&amp;nbsp;&lt;i&gt;DllImportAttribute&lt;/i&gt;&amp;nbsp;attribute, which has extra parameters that require knowledge of Win32 and other details that don&#39;t pertain to this lesson. Many other attributes can be used with both positional and named parameters.&lt;br /&gt;
&lt;h4 style=&quot;color: steelblue; font-size: 16px;&quot;&gt;Attribute Targets&lt;/h4&gt;The attributes shown so far have been applied to methods, but there are many other C# language elements that you can use attributes with. table outlines the C# language elements that attributes may be applied to. They are formally called attribute &quot;targets&quot;.&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; id=&quot;AutoNumber1&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Attribute Target&lt;/th&gt;&lt;th&gt;Can be Applied To&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;all&lt;/td&gt;&lt;td&gt;everything&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;assembly&lt;/td&gt;&lt;td&gt;entire assembly&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;class&lt;/td&gt;&lt;td&gt;classes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;constructor&lt;/td&gt;&lt;td&gt;constructors&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;delegate&lt;/td&gt;&lt;td&gt;delegates&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;enum&lt;/td&gt;&lt;td&gt;enums&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;event&lt;/td&gt;&lt;td&gt;events&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;field&lt;/td&gt;&lt;td&gt;fields&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;interface&lt;/td&gt;&lt;td&gt;interfaces&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;method&lt;/td&gt;&lt;td&gt;methods&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;module&lt;/td&gt;&lt;td&gt;modules (compiled code that can be part of an assembly)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;parameter&lt;/td&gt;&lt;td&gt;parameters&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;property&lt;/td&gt;&lt;td&gt;properties&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;returnvalue&lt;/td&gt;&lt;td&gt;return values&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;struct&lt;/td&gt;&lt;td&gt;structures&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Whenever there is ambiguity in how an attribute is applied, you can add a target specification to ensure the right language element is decorated properly. An attribute that helps ensure assemblies adhere to the Common Language Specification (CLS) is the&amp;nbsp;&lt;i&gt;CLSCompliantAttribute&lt;/i&gt;&amp;nbsp;attribute. The CLS is the set of standards that enable different .NET languages to communicate. Attribute targets are specified by prefixing the attribute name with the target and separating it with a colon (&lt;i&gt;:&lt;/i&gt;). Listing 16-3 shows how to use the&amp;nbsp;&lt;i&gt;CLSCompliantAttribute&lt;/i&gt;attribute and apply it to the entire assembly.&lt;br /&gt;
&lt;h5 style=&quot;color: grey; font-size: 12px;&quot;&gt;Listing 16-3. Using Positional and Named Attribute Parameters: AttributeTargetdemo.cs&lt;/h5&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;System;&lt;br /&gt;
&lt;br /&gt;
[assembly:CLSCompliant(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;)]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;br /&gt;
public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;AttributeTargetdemo&lt;br /&gt;
{&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;NonClsCompliantMethod(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;nclsParam)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine(&quot;Called NonClsCompliantMethod().&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [STAThread]&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; static&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;Main(&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;[] args)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;myUint = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AttributeTargetdemo tgtdemo =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;AttributeTargetdemo();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgtdemo.NonClsCompliantMethod(myUint);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;br /&gt;
The code will generate a compiler warning because of the&amp;nbsp;&lt;i&gt;uint&lt;/i&gt;&amp;nbsp;type parameter declared on the&amp;nbsp;&lt;i&gt;NonClsCompliantMethod()&lt;/i&gt;&amp;nbsp;method. If you change the&amp;nbsp;&lt;i&gt;CLSCompliantAttribute&lt;/i&gt;attribute to false or change the type of the&amp;nbsp;&lt;i&gt;NonClsCompliantMethod()&lt;/i&gt;&amp;nbsp;method to a CLS compliant type, such as&amp;nbsp;&lt;i&gt;int&lt;/i&gt;, the program will compile without warnings.&lt;br /&gt;
The point about Listing 16-3 is that the&amp;nbsp;&lt;i&gt;CLSCompliantAttribute&lt;/i&gt;&amp;nbsp;attribute is decorated with an attribute target of&amp;nbsp;&lt;i&gt;&quot;assembly&quot;&lt;/i&gt;. This causes all members of this assembly to be evaluated according to the&amp;nbsp;&lt;i&gt;CLSCompliantAttribute&lt;/i&gt;&amp;nbsp;attribute setting. To limit the scope of the&amp;nbsp;&lt;i&gt;CLSCompliantAttribute&lt;/i&gt;, apply it to either the&amp;nbsp;&lt;i&gt;AttributeTargetdemo&lt;/i&gt;&amp;nbsp;class or&amp;nbsp;&lt;i&gt;NonClsCompliantMethod()&lt;/i&gt;method directly.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/4571478914235237325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/how-can-use-attributes-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/4571478914235237325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/4571478914235237325'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/07/how-can-use-attributes-in-c.html' title='How can use attributes in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-7350400097308806403</id><published>2011-06-20T04:19:00.000-07:00</published><updated>2011-06-21T00:32:21.449-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Error Provider"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How can use an error provider control in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana; font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;Enter the ErrorProvider&lt;/span&gt;&lt;/h2&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;img height=&quot;284&quot; src=&quot;http://www.developerfusion.com/res/content/4445/Image1/&quot; width=&quot;344&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Figure 2:&amp;nbsp; Using the Error Provider to Show Non-Failure Related Information&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;To use an error provider control, merely drop one from the toolbox onto the form; you may use a single error provider control to mark any and all of the fields on a form, in this respect, using the error provider is similar to using the tool tip control.&amp;nbsp;Once the control has been placed on the form, it may be controlled programmatically.&lt;br /&gt;
&lt;br /&gt;
Normally one would write a custom validation method for each of the controls and test the control&#39;s content against that validation method whenever that specific control is validated. It is also possible to write a simple method to validate each of the fields in response to something like button click event.&amp;nbsp;In the example provided, there is &quot;Validate All&quot; button that does test each of the controls on the form and mark any which contain invalid data.&lt;br /&gt;
&lt;br /&gt;
The example is used to validate the contents of some text box controls.&amp;nbsp;Naturally it is just as easy to validate other controls such as a combo box control although it most likely going to be used with text box controls.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;Getting Started&lt;br /&gt;
&lt;/strong&gt;There is a single solution contained in the demo project included with this download.&amp;nbsp;This solution is a C# Windows Forms application that contains a single form.&amp;nbsp;On the form are eight different text boxes and each these text boxes are validated against a different set of criteria:&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Non-Empty String (any string with content)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Alpha Only String (a string containing alphas only)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Numeric Only String (a comprised of numbers only)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Range Validation (a number between 50 and 100)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Alphanumeric String (a string with alphas and/or numeric values)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Special Characters Only String (a string with only special characters)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Regular Expression (testing for a phone number)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;left&quot;&gt;Minimal Length String (a string with at least three characters)&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;Figure 3 (below) shows the solution explorer for the project.&amp;nbsp;The project is entitled UseErrorProvider; as can be seen in the figure, no additional references beyond the defaults were added to the project.&amp;nbsp;The single form included is entitled &quot;Form1&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;img alt=&quot;Image3.gif&quot; border=&quot;0&quot; height=&quot;295&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/scottlysle/UseErrorProvider03082007210138PM/Images/Image3.gif&quot; width=&quot;256&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Figure 3:&amp;nbsp; Solution Explorer with Both Projects Visible&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;The Project&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Code:&amp;nbsp; UseErrorProvider&lt;/strong&gt;&lt;br /&gt;
The application is very simple; in execution, when the application is started, the form will display eight text box controls.&amp;nbsp;Each of the controls has an event handler defined for the &quot;Validated&quot; event.&amp;nbsp;Each control is validated against a different validation method so along with the &quot;Validated&quot; event handler; a custom validation function has also been supplied.&amp;nbsp;Each of these custom validation functions is used to evaluate the content of the associated text box and to display an indication adjacent to the control if that control fails the validation test.&lt;br /&gt;
&lt;br /&gt;
The code starts off with the default imports; in addition to the defaults, the Regular Expression library has also been added to the code in order to support the evaluation of one of the text boxes against a regular expression.&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.Collections.Generic;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.ComponentModel;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.Data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.Drawing;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.Text;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.Windows.Forms;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;System.Text.RegularExpressions;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;namespace&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;UseErrorProvider&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;Using the error provider control - several examples&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Form1&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Form&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Form1()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;Form1_Load(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: green;&quot;&gt;// do nothing&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;The constructor and form load event handler are both in their default conditions. Following this section of code, the next thing up to look at is the validation handler for the non-empty string text box control:&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;Validate to make sure that the textbox contains&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;a string with at least one character&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtEmptyString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;bTest = txtEmptyStringIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.errorProvider1.SetError(txtEmptyString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This field must&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;contain text&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.errorProvider1.SetError(txtEmptyString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
There are couple of interesting things to note in this handler; first off note that a boolean is set to capture the results of a method called &quot;txtEmptyStringIsValid&quot;; this is the method that actually tests the contents of the text box to make sure that it is not empty.&amp;nbsp;As a result of the test, the error provider control is configured; if the string is empty, the error provider is associated with the text box control and the error provider&#39;s control is set to display &quot;This field must contain text&quot;.&amp;nbsp;If the string is not empty, the error provider is set to display nothing; this disables the error provider as applied to that control.&amp;nbsp;The result is that, whenever the text box control is validated, the test will execute and, if failed, the error provider icon will be displayed.&amp;nbsp;If the user hovers the cursor over the error provider&#39;s icon, the tool tip text will be displayed.&amp;nbsp;If the string is not empty, the error provider icon will not appear and there will be no tooltip.&lt;br /&gt;
&lt;br /&gt;
The method used to validate the control is as follows:&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;Test for empty string in the text box and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;return the results&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtEmptyStringIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(txtEmptyString.Text ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
This simple method is configured to return a boolean value; if the text box control contains text, the function will return false and no error provider indication will be shown on the form.&amp;nbsp;If the string is empty, the method will return true and the error provider will be used to mark the empty string text box.&amp;nbsp;This is essentially how all of the validation event handlers perform in this demo application; that is, the validation event handler calls the method used to test the associated control and then, as a result of that test, either the error indication is shown or not shown.&lt;br /&gt;
&lt;br /&gt;
The next item up is the validation event handler for the regular expression test text box:&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test the contents of this text box against a regular expression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtRegExString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest =&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;txtRegExStringIsValid(txtRegExString.Text.ToString());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtRegExString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This field must&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;contain a phone number (222-333-4444)&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtRegExString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;As before, the validation method is contained in separate method; that method evaluates the contents of the text box against a regular expression and marks or clears the error provider indication as a result of the outcome of that test.&amp;nbsp;The regular expression validation methods is as follows:&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test for a regex expression match in the text box and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;return the results - the example uses a regular&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;expression used to validate a phone number&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtRegExStringIsValid(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;textToValidate)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Regex&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;TheRegExpression;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;TheTextToValidate;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;TheRegExTest =&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;@&quot;[2-9]\d{2}-\d{3}-\d{4}&quot;&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TheTextToValidate = textToValidate;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TheRegExpression =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Regex&lt;/span&gt;(TheRegExTest);&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// test text with expression&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(TheRegExpression.IsMatch(TheTextToValidate))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;This method creates an instance of and populates a regular expression object.&amp;nbsp;The regular expression shown is used to validate a US telephone number.&amp;nbsp;The text to validate property is the contents of the associated text box control.&amp;nbsp;The regular expression object&#39;s &quot;IsMatch&quot; method is used to validate the text and, as a result of the test, the method returns a boolean value set to either true or false.&lt;br /&gt;
&lt;br /&gt;
The next validation event handler and custom validation method are used to validate that the text box control contains only numeric values.&amp;nbsp;The custom validation method also makes sure that the text box control is not empty.&amp;nbsp;To test the text box, the contents of the text box are dumped into a character array and each character in that array is evaluated to make sure that is does not contain non-numeric values.&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Validate that the textbox contains only numbers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtNumericString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest = txtNumericStringIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtNumericString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This field&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; must contain only numbers&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtNumericString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test for non-numeric values in the text box and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;also make sure the textbox is not empty&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtNumericStringIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(txtNumericString.Text ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;[] testArr = txtNumericString.Text.ToCharArray();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i = 0; i &amp;lt; testArr.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(!&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;.IsNumber(testArr[i]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
The next pair is used to validate on alphas only, it works essentially the same way as the previous example:&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test to validate that this textbox only contains&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;alphas&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtAlphaString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest = txtAlphaStringIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtAlphaString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This field must&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contain only alphas&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtAlphaString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test for non-alpha values in the text box and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;also make sure that the textbox is not empty&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtAlphaStringIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // first make sure the textbox contains something&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(txtAlphaString.Text ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // test each character in the textbox&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;[] testArr = txtAlphaString.Text.ToCharArray();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i = 0; i &amp;lt; testArr.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(!&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;.IsLetter(testArr[i]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
Next up is the range validation example; this example is used to test to see if the value entered is a numeric value between 50 and 100.&amp;nbsp;One thing interesting to note in this example is that two error providers are used; one shows up on valid entries and one shows up on invalid entries.&amp;nbsp;This was done to demonstrate using the control to show status other than failure (in the form of a confirmation of a good entry).&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
///&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Validate that the textbox contains a value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;that is between 50 and 100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtRangeValidation_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest = txtRangeValidationIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtRangeValidation,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This field&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; must contain a number between 50 and 100&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider2.SetError(txtRangeValidation,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtRangeValidation,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider2.SetError(txtRangeValidation,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;The value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;is between 50 and 100&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test for numeric values between 50 and 100 in the text box and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;return the results&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtRangeValidationIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;tmpVal = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmpVal =&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;Convert&lt;/span&gt;.ToInt32(txtRangeValidation.Text);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;{ }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(tmpVal &amp;lt; 100 &amp;amp;&amp;amp; tmpVal &amp;gt; 50)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;The next two validation examples each test the contents of the associated text boxes for different types of contents (alphanumeric, and special characters):&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Validate that the text box contains only numbers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;or letters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtAlphaNumericString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest = txtAlphaNumericStringIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtAlphaNumericString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;field must contain only alphanumerics&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtAlphaNumericString,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test for non-alpha values in the text box and&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;return the results&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtAlphaNumericStringIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Make sure the string is not empty first&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(txtAlphaNumericString.Text ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // check for alphanumeric values&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;[] testArr = txtAlphaNumericString.Text.ToCharArray();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i = 0; i &amp;lt; testArr.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(!&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;.IsLetter(testArr[i]) &amp;amp;&amp;amp; !&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;.IsNumber(testArr[i]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Validate that this text box contains only special characters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(non-alphanumerics)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtSpecialChars_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest = txtSpecialCharsIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtSpecialChars,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;This field&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;must contain only special characters&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtSpecialChars,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test for special character values in the textbox&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtSpecialCharsIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Make sure the string is not empty first&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(txtSpecialChars.Text ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;.Empty)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;[] testArr = txtSpecialChars.Text.ToCharArray();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i = 0; i &amp;lt; testArr.Length; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(!&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;.IsSymbol(testArr[i]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;(&lt;span style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;.IsLetterOrDigit(testArr[i]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;
The next example is used to validate that a text box contains a minimum number of characters (3):&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Validate that the text box contains a minimum&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;number of characters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtMinLengthTest_Validated(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;bTest = txtMinLengthTestIsValid();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(bTest ==&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtMinLengthTest,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: #a31515; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;This field must contain at least 3 characters&quot;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;.errorProvider1.SetError(txtMinLengthTest,&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Test to see that the textbox contains a minimum number&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;of characters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;txtMinLengthTestIsValid()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;[] testArr = txtMinLengthTest.Text.ToCharArray();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(testArr.Length &amp;lt; 3)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testBool =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;testBool;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;The last bit of code worth mentioning is used to validate all of the controls at the same time; this might be a useful thing to do to make sure all of the controls contain valid content prior to saving or posting data:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;Validate all of the controls at the same time from&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;a button click event handler&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;btnValidateAll_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt;&amp;nbsp;e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtEmptyString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtAlphaNumericString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtAlphaString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtMinLengthTest_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtNumericString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtRangeValidation_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtRegExString_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; txtSpecialChars_Validated(&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;, e);&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;This method merely calls for validation of each control; doing so will validate each control and will result in the display of error provider on each detected failure of the specific validations tests.&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;span style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif;&quot;&gt;&lt;strong&gt;Summary.&lt;br /&gt;
&lt;/strong&gt;This article was intended to demonstrate a few different ways in which one might implement the error provider in a Win Forms application. As was mentioned, the error provider be displayed in response to any custom validation methods and, subsequently it may be used to show either good or bad status information to the user.&lt;br /&gt;
&lt;br /&gt;
It should be noted also that you can prevent the entry of bad data into a control by writing handlers for the key press event.&amp;nbsp; For example, the following code will prevent the user from entering anything but numbers into a text box; it also allows the user to enter control keys so that things such as the backspace key will also work when the user enters text into the text box control.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;&amp;nbsp;txtDollarValue_KeyPress(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt;&amp;nbsp;sender,&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;KeyPressEventArgs&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;e)&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: green; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // allows only numbers&lt;/span&gt;&lt;span style=&quot;color: blue; font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;(!&lt;span style=&quot;color: #2b91af;&quot;&gt;Char&lt;/span&gt;.IsDigit(e.KeyChar) &amp;amp;&amp;amp; !&lt;span style=&quot;color: #2b91af;&quot;&gt;Char&lt;/span&gt;.IsControl(e.KeyChar))&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.Handled =&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span style=&quot;font-family: Verdana; font-size: 10pt; line-height: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/7350400097308806403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-can-use-error-provider-control-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7350400097308806403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7350400097308806403'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-can-use-error-provider-control-in.html' title='How can use an error provider control in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-1570112625111984610</id><published>2011-06-17T23:47:00.000-07:00</published><updated>2011-06-17T23:47:27.403-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="Random password generation"/><title type='text'>how to  Generating Random Passwords with ASP.NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Helvetica, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;The simplest random password generation scheme with ASP.NET is to return a portion of a GUID. A&amp;nbsp;&lt;a href=&quot;http://www.webopedia.com/TERM/G/GUID.html&quot; style=&quot;color: #336666; font-family: Verdana, Helvetica, sans-serif; text-decoration: underline;&quot;&gt;GUID&lt;/a&gt;&amp;nbsp;is a&amp;nbsp;&lt;i&gt;G&lt;/i&gt;lobally&amp;nbsp;&lt;i&gt;U&lt;/i&gt;nique ID, a 128-bit number that can be quickly generated with one method call, producing a hexidecimal string that can be used as a random password. To create a new GUID, use the&amp;nbsp;&lt;code&gt;System.Guid&lt;/code&gt;&amp;nbsp;structure&#39;s&amp;nbsp;&lt;code&gt;NewGuid()&lt;/code&gt;&amp;nbsp;method. Then, the&amp;nbsp;&lt;code&gt;.ToString()&lt;/code&gt;&amp;nbsp;method can be used to create a string version of this. Here&#39;s some example code:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Helvetica, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td bgcolor=&quot;#cccccc&quot; style=&quot;color: black; font-family: Verdana, Helvetica, sans-serif; font-size: 9pt; text-decoration: none;&quot; width=&quot;100%&quot;&gt;&lt;code&gt;&lt;pre&gt;public string GetRandomPasswordUsingGUID(int length)
{
  // Get the GUID
  string guidResult = System.Guid.NewGuid().ToString();
  
  // Remove the hyphens
  guidResult = guidResult.Replace(&quot;-&quot;, string.Empty);
  
  // Make sure length is valid
  if (length &amp;lt;= 0 || length &amp;gt; guidResult.Length)
    throw new ArgumentException(&quot;Length must be between 1 and &quot; + guidResult.Length);
  
  // Return the first length bytes
  return guidResult.Substring(0, length);
}
&lt;/pre&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
The following shows this output of this method when called with&amp;nbsp;&lt;i&gt;length&lt;/i&gt;&amp;nbsp;values of 5, 10, and 15, respectively. (Again, you can refresh the page and you&#39;ll see different random passwords, as each time&lt;code&gt;System.Guid.NewGuid()&lt;/code&gt;&amp;nbsp;is called, a new, unique identifier is created.)&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;&lt;blockquote&gt;Random password of length 5:17426&lt;br /&gt;
Random password of length 10: 63b7c416df&lt;br /&gt;
Random password of length 15: 6cc93d4277ac4ee&lt;/blockquote&gt;&lt;hr /&gt;&lt;br /&gt;
&lt;h2 class=&quot;section&quot; style=&quot;display: inline; font-size: 10pt;&quot;&gt;A More Robust Random Password Generator&lt;/h2&gt;&lt;br /&gt;
This nice thing about the GUID approach for creating random passwords is that it is easy to implement and use. However, it leaves you with no control over the resulting output, and only generates passwords with alphanumeric characters (and only with letters ranging from a to f). What if you want to impose certain security guidelines, such as requiring a random password with a certain number of non-alphanumeric characters, or a random password that uses a wider range of random characters (such as drawing from the entire alphabet)? Or what if, for some reason, you didn&#39;t want numbers in the random password? Or you wanted to make the password case-sensitive (again, with the GUID approach you only have six letters and they are all lowercase).A more robust solution would be to create a&amp;nbsp;&lt;code&gt;GeneratePassword(&lt;i&gt;length&lt;/i&gt;,&amp;nbsp;&lt;i&gt;numberOfNonAlphanumericCharacters&lt;/i&gt;)&lt;/code&gt;&amp;nbsp;password generator that mirrors the behavior of the ASP.NET 2.0 Membership API&#39;s method with the same name. This method - which is what you should use if you&#39;re using 2.0 - allows the page developer to specify the random password&#39;s length and the number of non-alphanumeric characters. Furthermore, it uses the&amp;nbsp;&lt;code&gt;RNGCryptoServiceProvider&lt;/code&gt;&amp;nbsp;class, which is a cryptographically strong random number generator. (In English, that means that the algorithm does not suffer from having characteristics which make it possible to better guess upcoming random numbers based on past random numbers produced.)&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/1570112625111984610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-generating-random-passwords-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1570112625111984610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1570112625111984610'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-generating-random-passwords-with.html' title='how to  Generating Random Passwords with ASP.NET'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-8750028967229987402</id><published>2011-06-17T22:35:00.000-07:00</published><updated>2011-06-17T22:35:49.082-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="Table"/><title type='text'>How to Handle Table In Asp.net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 class=&quot;page-title&quot; style=&quot;border-bottom-color: initial; border-bottom-style: initial; border-bottom-width: 0px; clear: left; color: #2e2e2e; font-family: Arial; font-size: 1.3em; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 10px; padding-bottom: 5px; padding-left: 0px; padding-right: 0px; padding-top: 5px;&quot;&gt;Table, TableRow, and TableCell Web Server Controls&lt;/h2&gt;&lt;div class=&quot;content&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div id=&quot;article-body&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;On a Web Forms page, the Table Web server control creates a general-purpose table. Rows in the table are created as TableRow Web server controls, and cells within each row are implemented as&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;Web server controls. The Table Web server control allows us to create server-programmable tables on our Web Forms page. The&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableRow&lt;/code&gt;&amp;nbsp;and&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;Web server controls provide a way to display the actual content for the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control.&lt;/div&gt;&lt;h2 style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: none; color: #2e2e2e; font-family: Arial; font-size: 1.3em; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 10px; padding-bottom: 5px; padding-left: 0px; padding-right: 0px; padding-top: 5px;&quot;&gt;Comparing the Table Web Server Control to Other Table Elements&lt;/h2&gt;&lt;div id=&quot;techclicks-zone-51&quot; style=&quot;border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 3px; clear: left; float: left; font-size: 12px; margin-bottom: 8px; margin-left: 0px; margin-right: 12px; margin-top: 3px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 3px; width: 140px;&quot;&gt;&lt;ul style=&quot;color: #cccccc; font-family: Arial, Helvetica, sans-serif; line-height: 13px; list-style-image: initial; list-style-position: outside; list-style-type: square; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 18px; padding-right: 3px; padding-top: 5px;&quot;&gt;&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: initial; background-image: none; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 12px; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 7px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #2e2e2e; font-family: Arial; line-height: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;strong style=&quot;font-style: inherit; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;a class=&quot;entity-ref&quot; href=&quot;http://www.developerfusion.com/t/html/&quot; style=&quot;color: #4d97e0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;HTML&lt;/a&gt;&amp;nbsp;table:&amp;nbsp;&lt;/strong&gt;We can add a&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;lt;TABLE&amp;gt;&lt;/code&gt;&amp;nbsp;element from the HTML tab of the Toolbox.&amp;nbsp;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;strong style=&quot;font-style: inherit; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;HtmlTable control:&amp;nbsp;&lt;/strong&gt;This is a&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;lt;TABLE&amp;gt;&lt;/code&gt;&amp;nbsp;HTML element that has been converted to a control by adding the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;runat=server&lt;/code&gt;attribute. We can program this control in server code.&amp;nbsp;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;strong style=&quot;font-style: inherit; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table Web Server control:&amp;nbsp;&lt;/strong&gt;A Web control that allows us to create and manipulate tables using an object model that is consistent with other Web controls (for example, adding table rows and cells).&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;In general, when we intend to add rows and cells (columns) to the table in code at run time, we use a Table Web server control. Although we can use it as a static table with predefined rows and columns, in that case it is easier to work with the HTML&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;lt;TABLE&amp;gt;&lt;/code&gt;&amp;nbsp;element.&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Because the Table Web server control offers an object model with typed properties that is consistent with other Web server controls, it can be easier to program than the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;HtmlTabl&lt;/code&gt;control. (The model is also consistent between the&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableRow&lt;/code&gt;, and&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;controls.)&lt;/div&gt;&lt;h2 style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: none; color: #2e2e2e; font-family: Arial; font-size: 1.3em; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 10px; padding-bottom: 5px; padding-left: 0px; padding-right: 0px; padding-top: 5px;&quot;&gt;Comparing the Table Web Server Control to Other List Web Server Controls&lt;/h2&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;We might accomplish some of the functions with a Table Web server control; we can also accomplish this with the list Web server controls: the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Repeater&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;DataList&lt;/code&gt;, and&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;DataGrid&lt;/code&gt;&amp;nbsp;controls. All of these controls render (or have the option to render) as HTML tables.&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;The differences between the list controls and the Table control are:&lt;/div&gt;&lt;ol style=&quot;color: #2e2e2e; font-family: Arial; list-style-image: initial; list-style-position: initial; list-style-type: decimal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 30px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;The list controls are data-bound; they work only against a data source, whereas the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control can display any combination of HTML text and controls, whether or not they are data-bound.&lt;/li&gt;
&lt;li style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;To specify the layout of their elements the list controls use templates. The&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control supports the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;child control, which we can fill as we would any HTML&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;lt;TD&amp;gt;&lt;/code&gt;&amp;nbsp;element.&lt;/li&gt;
&lt;/ol&gt;&lt;h2 style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: none; color: #2e2e2e; font-family: Arial; font-size: 1.3em; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 10px; padding-bottom: 5px; padding-left: 0px; padding-right: 0px; padding-top: 5px;&quot;&gt;Table Web Server Control Object Model&lt;/h2&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;For&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableRow&lt;/code&gt;&amp;nbsp;controls the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control acts as a parent control. The table supports a property called&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Rows&lt;/code&gt;&amp;nbsp;that is a collection of&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableRow&lt;/code&gt;&amp;nbsp;objects. We specify the rows for the table by managing this collection — adding or deleting items in it —. The&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableRow&lt;/code&gt;&amp;nbsp;control in turn supports a collection called&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Cells&lt;/code&gt;&amp;nbsp;of&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;objects.&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;The content to be displayed in the table is added to the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;control. The cell has a&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Text&lt;/code&gt;&amp;nbsp;property that we set to any HTML text. Alternatively, we can display controls in the cell by creating instances of, and adding controls to, the cell&#39;s Controls collection.&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;To control the appearance of the entire table, such as&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Font&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;BackColor&lt;/code&gt;, and&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;ForeColor&lt;/code&gt;, the parent&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control supports properties. These properties are supported by The&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableRow&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;controls as well, therefore, overriding the parent table appearance we can specify the look of individual rows or cells.&lt;/div&gt;&lt;h2 style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: none; color: #2e2e2e; font-family: Arial; font-size: 1.3em; margin-bottom: 5px; margin-left: 0px; margin-right: 0px; margin-top: 10px; padding-bottom: 5px; padding-left: 0px; padding-right: 0px; padding-top: 5px;&quot;&gt;Binding Data to the Control&lt;/h2&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;We can use the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control (unlike the list Web server controls; see above) to display data from a database although it is not inherently data bound.&lt;/div&gt;&lt;div style=&quot;color: #2e2e2e; font-family: Arial; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;We can bind any property of a&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;&amp;nbsp;control to a data source as with all Web server controls. However, the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Table&lt;/code&gt;control does not support a property that we use to display data directly. Instead, we typically add&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;controls to the table. We can then either bind the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Text&lt;/code&gt;&amp;nbsp;property of individual&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TableCell&lt;/code&gt;&amp;nbsp;controls to data, or we can add data-bound controls (such as a&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Label&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TextBox&lt;/code&gt;&amp;nbsp;control) to the cell.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/8750028967229987402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-table-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8750028967229987402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8750028967229987402'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-table-in-aspnet.html' title='How to Handle Table In Asp.net'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-3856264668612375953</id><published>2011-06-16T03:20:00.000-07:00</published><updated>2015-07-22T00:02:32.697-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="Button Controls"/><title type='text'>How To Add an image Button</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot;&gt;
&lt;img src=&quot;http://www.learn-asp.net/ASPTutorials/ASPTraining/ImageButtonImages/ImageButton_clip_image003.jpg&quot; height=&quot;73&quot; style=&quot;display: block;&quot; width=&quot;183&quot; /&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Using the cursor change the size of the imageButtons down to a small button&lt;/li&gt;
&lt;/ul&gt;
&lt;div align=&quot;center&quot;&gt;
&lt;img src=&quot;http://www.learn-asp.net/ASPTutorials/ASPTraining/ImageButtonImages/ImageButton_clip_image005.jpg&quot; height=&quot;130&quot; style=&quot;display: block;&quot; width=&quot;164&quot; /&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Add an Image control and name it&amp;nbsp;&lt;em&gt;bigImage&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div align=&quot;center&quot;&gt;
&lt;img src=&quot;http://www.learn-asp.net/ASPTutorials/ASPTraining/ImageButtonImages/ImageButton_clip_image007.jpg&quot; height=&quot;143&quot; style=&quot;display: block;&quot; width=&quot;391&quot; /&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Double click the imageButton and add this code:&lt;/li&gt;
&lt;/ul&gt;
bigImage.ImageUrl = sender.imageURL&lt;br /&gt;
We are going to use the same subroutine for each imagebutton&lt;br /&gt;
So instead of using smallimage1.imageURL we use the imageURL of the sending object. That way it does not matter which imageButton is clicked, that image will get put into the image control&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: #2e2e2e; font-family: Arial; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div align=&quot;center&quot; style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;b style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img src=&quot;http://www.developerfusion.com/res/content/3828/Image2/&quot; height=&quot;330&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; width=&quot;491&quot; /&gt;&amp;nbsp;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;Figure 14.2&lt;/b&gt;&lt;br /&gt;
The ImageButton example.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Here&#39;s the HTML created to support the image button you see in Figure 14.2; the image here is stored in the file map.jpg, which also comes with the code for this book:&lt;/div&gt;
&lt;code class=&quot;pre&quot; style=&quot;background-color: #fff8e1; clear: both; display: block; font-family: &#39;Lucida Console&#39;, monospace; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 620px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&amp;lt;input type=&quot;image&quot; name=&quot;ImageButton1&quot; id=&quot;ImageButton1&quot;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;src=&quot;file:///C:\inetpub\wwwroot\ImageButton\map.jpg&quot; border=&quot;0&quot;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;style=&quot;Z-INDEX: 102; LEFT: 2px; POSITION: absolute; TOP: 90px&quot; /&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Image buttons are supported with the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;System.Web.UI.WebControls.ImageButton&lt;/code&gt;&amp;nbsp;class; here is the hierarchy of this class:&lt;/div&gt;
&lt;code class=&quot;pre&quot; style=&quot;background-color: #fff8e1; clear: both; display: block; font-family: &#39;Lucida Console&#39;, monospace; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 620px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;System.Object&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; System.Web.UI.Control&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; &amp;nbsp; System.Web.UI.WebControls.WebControl&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; System.Web.UI.WebControls.Image&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.Web.UI.WebControls.ImageButton&lt;/code&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
You can find the significant public properties of&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;System.Web.UI.WebControls.ImageButton&lt;/code&gt;&amp;nbsp;objects in Table 14.2 and the significant public events in Table 14.3. (This class has no non-inherited methods.) Note that as with other Web server controls, these tables do not list the significant properties, methods, and events this class inherits from the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Control&lt;/code&gt;and&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;WebControl&lt;/code&gt;&amp;nbsp;classes—you can find them in Tables 12.1 to 12.5. Note also that this class inherits from the&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;System.Web.UI.WebControls.Image&lt;/code&gt;&amp;nbsp;class as well; you can find the public properties of that class in Table 14.1.&lt;/div&gt;
&lt;h4 style=&quot;color: black; font-size: 1em; font-weight: bold; margin-bottom: 3px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Table 14.2 Significant Public Properties of ImageButton Objects&lt;/h4&gt;
&lt;table class=&quot;articletable&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: collapse; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;tbody style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;tr style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;th style=&quot;background-color: #e6e6e6; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left;&quot;&gt;Property&lt;/th&gt;&lt;th style=&quot;background-color: #e6e6e6; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left;&quot;&gt;Means&lt;/th&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; valign=&quot;TOP&quot;&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;CommandArgument&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;Returns or sets an (optional) value holding text associated with the command given by the&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;CommandName&lt;/code&gt;&amp;nbsp;property.&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; valign=&quot;TOP&quot;&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;CommandName&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;Returns or sets the command name for this image button. If you assign a value to this property, the&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Command&lt;/code&gt;&amp;nbsp;event occurs when the button is clicked.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h4 style=&quot;color: black; font-size: 1em; font-weight: bold; margin-bottom: 3px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Table 14.3 Significant Public Events of ImageButton Objects&lt;/h4&gt;
&lt;table class=&quot;articletable&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; border-collapse: collapse; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;tbody style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;tr style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;th style=&quot;background-color: #e6e6e6; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left;&quot;&gt;Method&lt;/th&gt;&lt;th style=&quot;background-color: #e6e6e6; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left;&quot;&gt;Means&lt;/th&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Click&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;Occurs when the image button was clicked.&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Command&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f3f3f3; border-bottom-color: rgb(255, 255, 255); border-bottom-style: solid; border-bottom-width: 2px; border-left-color: rgb(255, 255, 255); border-left-style: solid; border-left-width: 2px; border-right-color: rgb(255, 255, 255); border-right-style: solid; border-right-width: 2px; border-top-color: rgb(255, 255, 255); border-top-style: solid; border-top-width: 2px; font-size: 11px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;Occurs when the image button was clicked and the&amp;nbsp;&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;CommandName&lt;/code&gt;&amp;nbsp;property holds some text—use a&amp;nbsp;&lt;code style=&quot;font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Command&lt;/code&gt;event handler to handle this one.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Image buttons are images that also support&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Click&lt;/code&gt;&amp;nbsp;events. When you handle&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Click&lt;/code&gt;&amp;nbsp;events in image buttons, you are passed the location of the mouse in the image in an&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;ImageClickEventArgs&lt;/code&gt;&amp;nbsp;object; that location is what you need when you want to create an image map that the user can click to perform some action.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
The position of the mouse is stored in pixels; the origin, (0, 0), is at the upper-left corner of the image. Here&#39;s how the ImageButton example displays the coordinates in the image at which the user clicked the mouse:&lt;/div&gt;
&lt;code class=&quot;pre&quot; style=&quot;background-color: #fff8e1; clear: both; display: block; font-family: &#39;Lucida Console&#39;, monospace; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 620px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;Private Sub ImageButton1_Click(ByVal sender As System.Object, _&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;ByVal e As System.Web.UI.ImageClickEventArgs) Handles _&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;ImageButton1.Click&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp;&amp;nbsp;&lt;b style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;TextBox1.Text = &quot;You clicked the image at &quot; &amp;amp; e.X &amp;amp; &quot;, &quot; &amp;amp; e.Y&lt;/b&gt;End Sub&lt;/code&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
You can see the results in&amp;nbsp;&lt;a href=&quot;http://www.developerfusion.com/article/3828/web-forms-working-with-aspnet-server-controls/3/&quot; style=&quot;color: #4d97e0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Figure 14.2&lt;/a&gt;. Image maps often let the user navigate to a new URL when you click a &quot;hotspot&quot; in them, and you can handle that with the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Response&lt;/code&gt;&amp;nbsp;object&#39;s&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Redirect&lt;/code&gt;&amp;nbsp;method. (See &quot;Creating a Multiform Web Application&quot; in Day 11, &quot;Creating Web Forms with&amp;nbsp;&lt;a class=&quot;entity-ref&quot; href=&quot;http://www.developerfusion.com/t/asp.net/&quot; style=&quot;color: #4d97e0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;ASP.NET&lt;/a&gt;,&quot; for more on the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Redirect&lt;/code&gt;&amp;nbsp;method.) Here&#39;s an example that makes the browser navigate to&amp;nbsp;&lt;a href=&quot;http://www.microsoft.com/&quot; style=&quot;color: #4d97e0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot; target=&quot;new&quot;&gt;http://www.microsoft.com&lt;/a&gt;&amp;nbsp;when the user clicks a region of the image—the rectangle stretching from (100, 50) to (200, 150)—which we&#39;ll treat as a hotspot:&lt;/div&gt;
&lt;code class=&quot;pre&quot; style=&quot;background-color: #fff8e1; clear: both; display: block; font-family: &#39;Lucida Console&#39;, monospace; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 620px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;Private Sub ImageButton1_Click(ByVal sender As System.Object, _&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;ByVal e As System.Web.UI.ImageClickEventArgs) Handles _&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;ImageButton1.Click&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp;&lt;b style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;nbsp;If (e.X &amp;gt;= 100 And e.X &amp;lt;= 200) And (e.Y &amp;gt;= 50 And e.Y &amp;lt;= 150) Then&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; &amp;nbsp; Response.Redirect(&quot;http://www.microsoft.com&quot;)&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; End If&lt;/b&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;End Sub&lt;/code&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
You can also use the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Command&lt;/code&gt;&amp;nbsp;event handler to make the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;ImageButton&lt;/code&gt;&amp;nbsp;control work like command buttons. In particular, you can connect a command name to the image button with the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;CommandName&lt;/code&gt;&amp;nbsp;property, and the&amp;nbsp;&lt;code style=&quot;font-size: 10px; font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;CommandArgument&lt;/code&gt;property can also be used to pass additional information about the command. Here&#39;s how you might put that to work in code:&lt;/div&gt;
&lt;code class=&quot;pre&quot; style=&quot;background-color: #fff8e1; clear: both; display: block; font-family: &#39;Lucida Console&#39;, monospace; font-size: 11px; font-style: normal; font-weight: normal; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-width: 620px; overflow-x: auto; overflow-y: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;Private Sub ImageButton1_Command(ByVal sender As Object, _&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;ByVal e As System.Web.UI.WebControls.CommandEventArgs) _&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;Handles ImageButton1.Command&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp;&amp;nbsp;&lt;b style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;If e.CommandName = &quot;NavigateButton&quot; Then&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; &amp;nbsp; TextBox1.Text = e.CommandArgument&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&amp;nbsp; End If&lt;/b&gt;End Sub&lt;/code&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/3856264668612375953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-add-image-button.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/3856264668612375953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/3856264668612375953'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-add-image-button.html' title='How To Add an image Button'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-4471091936856507672</id><published>2011-06-16T03:08:00.000-07:00</published><updated>2011-06-16T03:41:36.544-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Chat"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How to Handle Chat application in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;img height=&quot;456&quot; src=&quot;http://www.codeproject.com/KB/IP/TCPIPChat/ScreenShot.jpg&quot; style=&quot;overflow-x: auto; overflow-y: auto;&quot; width=&quot;600&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Sockets&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;In socket-based network programming, you don&#39;t directly access the network interface device to send and receive packets. Instead, an intermediary connector is created to handle the programming interface to the network. Assume that a socket is a connector that connects your application to a network interface of your computer. For sending and receiving data to and from the network you should call the socket&#39;s methods.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Socket programming in C#&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The &#39;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;System.Net.Sockets&lt;/code&gt;&#39; namespace contains the classes that provide the actual .NET interface to the low-level Winsock APIs. In network programming, apart from which programming language to use there are some common concepts like the IP address and port. IP address is a unique identifier of a computer on a network and port is like a gate through which applications communicate with each other. In brief, when we want to communicate with a remote computer or a device over the network, we should know its IP address. Then, we must open a gate (Port) to that IP and then send and receive the required data.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;IP addresses in C#&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;One of the biggest advantages you will notice in the .NET network library is the way IP address/port pairs are handled. It is a fairly straightforward process that presents a welcome improvement over the old, confusing UNIX way. .NET defines two classes in the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;System.Net&lt;/code&gt;&amp;nbsp;namespace to handle various types of IP address information:&lt;/div&gt;&lt;ul&gt;&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPAddress&lt;/code&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPEndPoint&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h3 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 11pt; font-weight: bold; line-height: 1.2em;&quot;&gt;IPAddress&lt;/h3&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;An&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPAddress&lt;/code&gt;&amp;nbsp;object is used to represent a single IP address. This value is then used in various socket methods to represent the IP address. The default constructor for&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPAddress&lt;/code&gt;&amp;nbsp;is as follows:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain0&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg0&quot; preid=&quot;0&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse0&quot; preid=&quot;0&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre0&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; IPAddress(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;long&lt;/span&gt; address)&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The default constructor takes a&amp;nbsp;&lt;code lang=&quot;cs&quot; style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;long&lt;/span&gt;&lt;/code&gt;&amp;nbsp;value and converts it to an&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPAddress&lt;/code&gt;&amp;nbsp;value. In practice, the default is almost never used. Instead, several methods in the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPAddress&lt;/code&gt;&amp;nbsp;class can be used to create and manipulate IP addresses. The&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Parse()&lt;/code&gt;&amp;nbsp;method is often used to create&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPAddress&lt;/code&gt;&amp;nbsp;instances:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain1&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg1&quot; preid=&quot;1&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse1&quot; preid=&quot;1&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre1&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;IPAddress newaddress = IPAddress.Parse(&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;192.168.1.1&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;h3 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 11pt; font-weight: bold; line-height: 1.2em;&quot;&gt;IPEndPoint&lt;/h3&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The .NET Framework uses the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPEndPoint&lt;/code&gt;&amp;nbsp;object to represent a specific IP address/port combination. An&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPEndPoint&lt;/code&gt;&amp;nbsp;object is used when binding sockets to local addresses, or when connecting sockets to remote addresses.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Connection-oriented and connectionless sockets&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The world of IP connectivity revolves around two types of communication: connection-oriented and connectionless. In a connection-oriented socket, the TCP protocol is used to establish a session (connection) between two IP address endpoints. There is a fair amount of overhead involved with establishing the connection, but once it is established, the data can be reliably transferred between the devices.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Connectionless sockets use the UDP protocol. Because of that no connection information is required to be sent between the network devices and it is often difficult to determine which device is acting as a &quot;server&quot;, and which is acting as a &quot;client&quot;. We will focus on the first type of socket programming in this article.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Using connection-oriented sockets&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;In the .NET Framework, you can create connection-oriented communications with remote hosts across a network. To create a connection-oriented socket, separate sequences of functions must be used for server programs and client programs:&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;&lt;img height=&quot;285&quot; src=&quot;http://www.codeproject.com/KB/IP/TCPIPChat/ClientServer.jpg&quot; style=&quot;overflow-x: auto; overflow-y: auto;&quot; width=&quot;310&quot; /&gt;&lt;/div&gt;&lt;h3 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 11pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Server&lt;/h3&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;You have four tasks to perform before a server can transfer data with a client connection:&lt;/div&gt;&lt;ol&gt;&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Create a socket.&lt;/li&gt;
&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Bind the socket to a local&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;IPEndPoint&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Place the socket in listen mode.&lt;/li&gt;
&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Accept an incoming connection on the socket.&lt;/li&gt;
&lt;/ol&gt;&lt;h4 style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Creating the server&lt;/h4&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The first step to constructing a TCP server is to create an instance of the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Socket&lt;/code&gt;&amp;nbsp;object. The other three functions necessary for successful server operations are then accomplished by using the methods of&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Socket&lt;/code&gt;&amp;nbsp;object. The following C# code snippet includes these steps:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain2&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg2&quot; preid=&quot;2&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse2&quot; preid=&quot;2&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre2&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;IPEndPoint localEndPoint = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; IPEndPoint(IPAddress.Any, &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;8000&lt;/span&gt;);
Socket newsock = Socket(AddressFamily.InterNetwork,
                   SocketType.Stream, ProtocolType.Tcp);
newsock.Bind(localEndPoint);
newsock.Listen(&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;10&lt;/span&gt;);
Socket client = newsock.Accept();&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Socket&lt;/code&gt;&amp;nbsp;object created by the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Accept()&lt;/code&gt;&amp;nbsp;method can now be used to transmit data in either direction between the server and the remote client.&lt;/div&gt;&lt;h3 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 11pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Client&lt;/h3&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Now that you have a working TCP server, you can create a simple TCP client program to interact with it. There are only two steps required to connect a client program to a TCP server:&lt;/div&gt;&lt;ol&gt;&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Create a socket.&lt;/li&gt;
&lt;li style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Connect the socket to the remote server address.&lt;/li&gt;
&lt;/ol&gt;&lt;h4 style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Creating the client&lt;/h4&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;As it was for the server program, the first step for creating the client program is to create a&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Socket&lt;/code&gt;&amp;nbsp;object. The&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Socket&lt;/code&gt;&amp;nbsp;object is used by the socket&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Connect()&lt;/code&gt;&amp;nbsp;method to connect the socket to a remote host:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain3&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg3&quot; preid=&quot;3&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse3&quot; preid=&quot;3&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre3&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;IPEndPoint ipep = 
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; IPEndPoint(Ipaddress.Parse(&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;127.0.0.1&quot;&lt;/span&gt;), &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;8000&lt;/span&gt;);
Socket server = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Socket(AddressFamily.InterNetwork,
                  SocketType.Stream, ProtocolType.Tcp);
server.Connect(ipep);&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;This example attempts to connect the socket to the server located at address 127.0.0.1.This is the IP address of the local host (current computer) and is a loopback IP for testing a network application without a network. Of course, you can also use hostnames along with the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Dns.Resolve()&lt;/code&gt;&amp;nbsp;method in a real network. (Dns is in&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;System.Net&lt;/code&gt;namespace). Once the remote server TCP program accepts the connection request, the client program is ready to transmit data with the server using the standard&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Send()&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Receive()&lt;/code&gt;&amp;nbsp;methods.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Blocking problem of network applications&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Sockets are in blocking mode by default. In this mode they will wait forever to complete their functions, holding up other functions within the application program until they are complete. Many programs can work quite competently in this mode, but for applications that work in the Windows programming environment, this can be a problem. There are some ways to solve this problem. The first thing that comes to a programmer&#39;s mind is multi threading. I chose this solution in my application too. This is a simple way when compared to asynchronous network programming or the old &#39;Non-Blocking sockets&#39; way.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Our command client/server&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;After a brief introduction on network programming in C#, I should give you more details about our command client/server application here. Of course, I can&#39;t write a book on network programming in this little article. This is only an introduction to network programming. You can find many samples and tutorials on MSDN and CodeProject explaining this concept in detail.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;About the command server&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The server application is a console program. After starting, it will bind to the &#39;127.0.0.1&#39; local IP and wait on the port 8000 by default for clients. You can pass the IP and the port of the server as the first and second command line parameters when starting the server, if you have a real network. For example:&amp;nbsp;&lt;i&gt;c:\&amp;gt; ConsoleServer 192.198.0.100 8960&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;I used&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;BackgroundWorker&lt;/code&gt;&amp;nbsp;to implement multithreading in time consuming functions in the server and client. One of these actions includes the acceptance part of the server:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain4&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg4&quot; preid=&quot;4&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse4&quot; preid=&quot;4&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre4&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;bwListener = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; BackgroundWorker();
bwListener.DoWork += &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; DoWorkEventHandler(StartToListen);
bwListener.RunWorkerAsync();

&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; StartToListen(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender , DoWorkEventArgs e)
{
   &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.listenerSocket = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Socket(AddressFamily.InterNetwork, 
                           SocketType.Stream, ProtocolType.Tcp);
   &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.listenerSocket.Bind(
               &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; IPEndPoint(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.serverIP , &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.serverPort));
   &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.listenerSocket.Listen(&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;200&lt;/span&gt;);
   &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; ( &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;true&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.CreateNewClientManager(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.listenerSocket.Accept());
}&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;I have a class named&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;ClientManager&lt;/code&gt;. When the server is connected to a remote client it passes the communication socket to this class and adds this new&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;ClientManager&lt;/code&gt;&amp;nbsp;object to a list of current connected remote clients. Each&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;ClientManager&lt;/code&gt;&amp;nbsp;object in the list is responsible for communicating with its remote client. The&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;ClientManager&lt;/code&gt;&amp;nbsp;object announces the server with various events defined in this class when an action takes place between the remote client and the server. These events are:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain5&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg5&quot; preid=&quot;5&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse5&quot; preid=&quot;5&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre5&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; CommandReceivedEventHandler CommandReceived;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a command is received from a remote client.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain6&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg6&quot; preid=&quot;6&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse6&quot; preid=&quot;6&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre6&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; CommandSentEventHandler CommandSent;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a command had been sent to the remote client successfully.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain7&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg7&quot; preid=&quot;7&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse7&quot; preid=&quot;7&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre7&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; CommandSendingFailedEventHandler CommandFailed;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a command sending action fails. This is may be because of disconnection or sending exception.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain8&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg8&quot; preid=&quot;8&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse8&quot; preid=&quot;8&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre8&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; DisconnectedEventHandler Disconnected;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a client is disconnected from this server.&lt;/div&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;Sending and receiving data&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Since we have a command client/server application we should have a command object to send and receive data. This is implemented in a &#39;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Command&lt;/code&gt;&#39; class. This class is the same in client and server. When the server wants to send a command to the client it builds a&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Command&lt;/code&gt;&amp;nbsp;object and then sends it to the client and vice versa.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;command&lt;/code&gt;&amp;nbsp;class is good for the user of this code. But in the network, we can&#39;t send and receive an object or a type. Everything should be converted to&amp;nbsp;&lt;code lang=&quot;cs&quot; style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;&lt;/code&gt;&amp;nbsp;array. So, we should convert this object to a&amp;nbsp;&lt;code lang=&quot;cs&quot; style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt;&lt;/code&gt;&amp;nbsp;array part by part and send or receive it over the network in real&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Send&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;Receive&lt;/code&gt;&amp;nbsp;functions inside our code. The following code shows the&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;send&lt;/code&gt;&amp;nbsp;command method. &#39;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;cmd&lt;/code&gt;&#39; is the command that we want to send to the remote client:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain9&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg9&quot; preid=&quot;9&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse9&quot; preid=&quot;9&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre9&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Type
&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [] buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
buffer = BitConverter.GetBytes((&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;)cmd.CommandType);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();

&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Sender IP
&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [] senderIPBuffer = 
     Encoding.ASCII.GetBytes(cmd.SenderIP.ToString());
buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
buffer = BitConverter.GetBytes(senderIPBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(senderIPBuffer, &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;, 
                               senderIPBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();
                
&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Sender Name
&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [] senderNameBuffer = 
   Encoding.Unicode.GetBytes(cmd.SenderName.ToString());
buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
buffer = BitConverter.GetBytes(senderNameBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(senderNameBuffer, &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;, 
                               senderNameBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();
                
&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Target
&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [] ipBuffer = 
  Encoding.ASCII.GetBytes(cmd.Target.ToString());
buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
buffer = BitConverter.GetBytes(ipBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(ipBuffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , ipBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();

&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Meta Data.
&lt;/span&gt;
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( cmd.MetaData == &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;null&lt;/span&gt; || cmd.MetaData == &lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt; )
    cmd.MetaData = &lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;\n&quot;&lt;/span&gt;;

&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [] metaBuffer = 
          Encoding.Unicode.GetBytes(cmd.MetaData);
buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
buffer = BitConverter.GetBytes(metaBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Write(metaBuffer, &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;, metaBuffer.Length);
&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Flush();&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;send&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;receive&lt;/code&gt;&amp;nbsp;are bidirectional operations. For example, when we send 4 bytes to the client, the client should read the 4 bytes. We should repeat this operation until all the sent data is read. See the receive code of the client here:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain10&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg10&quot; preid=&quot;10&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse10&quot; preid=&quot;10&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre10&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; ( &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.clientSocket.Connected )
{
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s Type.
&lt;/span&gt;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [] buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    CommandType cmdType = 
         (CommandType)( BitConverter.ToInt32(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;) );
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s sender ip size.
&lt;/span&gt;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; senderIPSize = BitConverter.ToInt32(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;);
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s sender ip.
&lt;/span&gt;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [senderIPSize];
    readBytes = 
        &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , senderIPSize);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    IPAddress senderIP = IPAddress.Parse(
             System.Text.Encoding.ASCII.GetString(buffer));
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s sender name size.
&lt;/span&gt;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; senderNameSize = BitConverter.ToInt32(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;);
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s sender name.
&lt;/span&gt;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [senderNameSize];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer, &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;, senderNameSize);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; senderName = 
        System.Text.Encoding.Unicode.GetString(buffer);
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s target size.
&lt;/span&gt;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; cmdTarget = &lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
       &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ipSize = BitConverter.ToInt32(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;);
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s target.
&lt;/span&gt;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [ipSize];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , ipSize);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    cmdTarget = System.Text.Encoding.ASCII.GetString(buffer);
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s MetaData size.
&lt;/span&gt;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;string&lt;/span&gt; cmdMetaData = &lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;code-string&quot; style=&quot;color: purple;&quot;&gt;&quot;&lt;/span&gt;;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [&lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;4&lt;/span&gt;);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
      &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; metaDataSize = BitConverter.ToInt32(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt;);
    
    &lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;code-comment&quot; style=&quot;color: green; font-style: italic;&quot;&gt;Read the command&#39;s Meta data.
&lt;/span&gt;
    buffer = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;byte&lt;/span&gt; [metaDataSize];
    readBytes = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.networkStream.Read(buffer , &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; , metaDataSize);
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ( readBytes == &lt;span class=&quot;code-digit&quot; style=&quot;color: navy;&quot;&gt;0&lt;/span&gt; )
         &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
    cmdMetaData = System.Text.Encoding.Unicode.GetString(buffer);
                  
    Command cmd = &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; Command(cmdType, 
                        IPAddress.Parse(cmdTarget), cmdMetaData);
    cmd.SenderIP = senderIP;
    cmd.SenderName = senderName;
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.OnCommandReceived(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; CommandEventArgs(cmd));
    }
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.OnServerDisconnected(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; ServerEventArgs(&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.clientSocket));
    &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.Disconnect();
}&lt;/pre&gt;&lt;h2 style=&quot;color: #ff9900; font-family: Verdana, Arial, sans-serif; font-size: 13pt; font-weight: bold; line-height: 1.2em;&quot;&gt;About the command client&lt;/h2&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;The command client is very similar to the server. Everything is in the &#39;&lt;code style=&quot;color: #990000; font: normal normal normal 11pt/normal &#39;Courier New&#39;, Courier, mono;&quot;&gt;CommandClient&lt;/code&gt;&#39; class. Since our application is an event driven program this class also has some events to announce the user of the occurred actions. Here is a brief definition of these events:&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain11&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg11&quot; preid=&quot;11&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse11&quot; preid=&quot;11&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre11&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; CommandReceivedEventHandler CommandReceived;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a command is received from a remote client.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain12&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg12&quot; preid=&quot;12&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse12&quot; preid=&quot;12&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre12&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; CommandSentEventHandler CommandSent;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a command has been sent to the remote server successfully.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain13&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg13&quot; preid=&quot;13&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse13&quot; preid=&quot;13&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre13&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; CommandSendingFailedEventHandler CommandFailed;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when a command sending action fails. This is because of disconnection or sending exception.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain14&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg14&quot; preid=&quot;14&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse14&quot; preid=&quot;14&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre14&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; ServerDisconnectedEventHandler ServerDisconnected;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when the client is disconnected.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain15&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg15&quot; preid=&quot;15&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse15&quot; preid=&quot;15&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre15&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; DisconnectedEventHandler DisconnectedFromServer;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when this client is disconnected from the remote server.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain16&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg16&quot; preid=&quot;16&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse16&quot; preid=&quot;16&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre16&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; ConnectingSuccessedEventHandler ConnectingSuccessed;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when this client is connected to the remote server successfully.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain17&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg17&quot; preid=&quot;17&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse17&quot; preid=&quot;17&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre17&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; ConnectingFailedEventHandler ConnectingFailed;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when this client fails on connecting to the server.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain18&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg18&quot; preid=&quot;18&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse18&quot; preid=&quot;18&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre18&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; NetworkDeadEventHandler NetworkDead;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when the network fails.&lt;/div&gt;&lt;div class=&quot;small-text align-right&quot; id=&quot;premain19&quot; style=&quot;display: block; font-size: 8pt !important; text-align: right !important;&quot; width=&quot;100%&quot;&gt;&lt;img height=&quot;9&quot; id=&quot;preimg19&quot; preid=&quot;19&quot; src=&quot;http://www.codeproject.com/images/minus.gif&quot; style=&quot;cursor: pointer; overflow-x: auto; overflow-y: auto;&quot; width=&quot;9&quot; /&gt;&lt;span id=&quot;precollapse19&quot; preid=&quot;19&quot; style=&quot;cursor: pointer; margin-bottom: 0px;&quot;&gt;&amp;nbsp;Collapse&lt;/span&gt;&lt;/div&gt;&lt;pre id=&quot;pre19&quot; lang=&quot;cs&quot; style=&quot;background-color: #fbedbb; border-bottom-color: rgb(251, 237, 187); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(251, 237, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(251, 237, 187); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(251, 237, 187); border-top-style: solid; border-top-width: 1px; font: normal normal normal 9pt/normal &#39;Courier New&#39;, Courier, mono; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;code-keyword&quot; style=&quot;color: blue;&quot;&gt;event&lt;/span&gt; NetworkAlivedEventHandler NetworkAlived;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 10pt; line-height: 1.2em;&quot;&gt;Occurs when the network starts to work.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/4471091936856507672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-chat-application-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/4471091936856507672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/4471091936856507672'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-chat-application-in-c.html' title='How to Handle Chat application in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-1032565943813761927</id><published>2011-06-14T00:57:00.000-07:00</published><updated>2011-06-16T03:41:58.798-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Tree View"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How to handle a tree view in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 24px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;display: block; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;You want to get started using a&amp;nbsp;&lt;b&gt;TreeView&lt;/b&gt;&amp;nbsp;control in the .NET Framework and C# programming language. The TreeView control must have nodes added to it through the Nodes instance collection and can be inserted in the Visual Studio designer. It allows you to represent hierarchal text and icon data in a convenient and easy-to-deploy way. Here we walk through instructions for getting started with the TreeView control in the C# language, first adding nodes and creating a primitive hierarchy, and then adding an event handler to the control.&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-color: initial; border-style: initial; margin-right: 10px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;img alt=&quot;TreeView in Windows Forms&quot; height=&quot;300&quot; id=&quot;n&quot; src=&quot;http://www.dotnetperls.com/439&quot; style=&quot;border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; display: block; float: none; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: middle;&quot; width=&quot;300&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;margin-bottom: 0px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;Add nodes&lt;/span&gt;&lt;/h2&gt;&lt;div style=&quot;display: block; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;First, in this tutorial we add a TreeView control to the Windows Forms Application project. To do this, open the Toolbox panel by clicking on the View and then Toolbox menu item in Visual Studio. Then, double-click on the TreeView item. You can dock the TreeView to your window so it expands to fill the entire Windows Forms program window. Now, double-click on the Form1 window in the designer so you can create the Form1_Load event. In this event handler, we will insert code to build the nodes in the TreeView control.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;display: block; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;display: block; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;EXAMPLE &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;display: block; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;display: block; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: normal; white-space: nowrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Collections;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.ComponentModel;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Data;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;namespace&amp;nbsp;TreeViewExample&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Summary&amp;nbsp;description&amp;nbsp;for&amp;nbsp;TreeViewExample.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TreeViewExample&amp;nbsp;:&amp;nbsp;System.Windows.Forms.Form&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;internal&amp;nbsp;System.Windows.Forms.TreeView&amp;nbsp;treeFood;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Required&amp;nbsp;designer&amp;nbsp;variable.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.ComponentModel.Container&amp;nbsp;components&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TreeViewExample&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Required&amp;nbsp;for&amp;nbsp;Windows&amp;nbsp;Form&amp;nbsp;Designer&amp;nbsp;support&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;InitializeComponent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;TODO:&amp;nbsp;Add&amp;nbsp;any&amp;nbsp;constructor&amp;nbsp;code&amp;nbsp;after&amp;nbsp;InitializeComponent&amp;nbsp;call&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Clean&amp;nbsp;up&amp;nbsp;any&amp;nbsp;resources&amp;nbsp;being&amp;nbsp;used.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;protected&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;override&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Dispose&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;bool&amp;nbsp;disposing&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;disposing&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;components&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;components.Dispose&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;base.Dispose&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;disposing&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;#region&amp;nbsp;Windows&amp;nbsp;Form&amp;nbsp;Designer&amp;nbsp;generated&amp;nbsp;code&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Required&amp;nbsp;method&amp;nbsp;for&amp;nbsp;Designer&amp;nbsp;support&amp;nbsp;-&amp;nbsp;do&amp;nbsp;not&amp;nbsp;modify&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;the&amp;nbsp;contents&amp;nbsp;of&amp;nbsp;this&amp;nbsp;method&amp;nbsp;with&amp;nbsp;the&amp;nbsp;code&amp;nbsp;editor.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;InitializeComponent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.TreeView&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.SuspendLayout&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;treeFood&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.Anchor&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.AnchorStyles.Top&amp;nbsp;|&amp;nbsp;System.Windows.Forms.AnchorStyles.Bottom&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;|&amp;nbsp;System.Windows.Forms.AnchorStyles.Left&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;|&amp;nbsp;System.Windows.Forms.AnchorStyles.Right&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.ImageIndex&amp;nbsp;=&amp;nbsp;-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.Location&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Point&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;treeFood&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.SelectedImageIndex&amp;nbsp;=&amp;nbsp;-&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.Size&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;284&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;256&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.TabIndex&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood.AfterSelect&amp;nbsp;+=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.TreeViewEventHandler&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood_AfterSelect&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;TreeViewExample&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.AutoScaleBaseSize&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.ClientSize&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;292&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;266&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Controls.AddRange&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Control&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.treeFood&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;TreeViewExample&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;TreeView&amp;nbsp;Example&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Load&amp;nbsp;+=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.EventHandler&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.TreeViewExample_Load&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.ResumeLayout&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;#endregion&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;The&amp;nbsp;main&amp;nbsp;entry&amp;nbsp;point&amp;nbsp;for&amp;nbsp;the&amp;nbsp;application.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;STAThread&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Application.Run&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TreeViewExample&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TreeViewExample_Load&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;object&amp;nbsp;sender,&amp;nbsp;System.EventArgs&amp;nbsp;e&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TreeNode&amp;nbsp;node;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node&amp;nbsp;=&amp;nbsp;treeFood.Nodes.Add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Fruits&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node.Nodes.Add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Apple&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node.Nodes.Add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Peach&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node&amp;nbsp;=&amp;nbsp;treeFood.Nodes.Add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Vegetables&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node.Nodes.Add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Tomato&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node.Nodes.Add&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Eggplant&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;treeFood_AfterSelect&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;object&amp;nbsp;sender,&amp;nbsp;System.Windows.Forms.TreeViewEventArgs&amp;nbsp;e&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;e.Action&amp;nbsp;==&amp;nbsp;TreeViewAction.ByMouse&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MessageBox.Show&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;e.Node.FullPath&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-family: verdana, sans-serif; font-size: 17px; margin-bottom: 12px; margin-left: 10px; margin-right: 10px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/1032565943813761927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-tree-view-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1032565943813761927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1032565943813761927'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-tree-view-in-c.html' title='How to handle a tree view in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-1549518766333250554</id><published>2011-06-14T00:50:00.000-07:00</published><updated>2011-06-16T03:43:50.034-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Base Application"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>how to use the sql dataadapter in c#</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, sans-serif; font-size: 17px; line-height: 24px;&quot;&gt;You want to see an example of&amp;nbsp;&lt;b&gt;SqlDataAdapter&lt;/b&gt;&amp;nbsp;and its usage in the C# language. This is to fill a DataTable with a table from your SQL Server database. Here we see a quick example, and a table reviewing various SqlDataAdapter members.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Segoe UI&#39;, Verdana, Arial; font-size: 13px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;public DataSet SelectSqlSrvRows(DataSet dataset,string connection,string query) 
{
    SqlConnection connection= new SqlConnection(connectionstring);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(query, connection);&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;Dataset ds=new Dataset()
    adapter.Fill(ds);
    return dataset;
}
&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/1549518766333250554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-use-sql-dataadapter-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1549518766333250554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1549518766333250554'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-use-sql-dataadapter-in-c.html' title='how to use the sql dataadapter in c#'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-5936546162166068670</id><published>2011-06-09T10:16:00.000-07:00</published><updated>2011-06-16T03:48:56.231-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Menustrip"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How to use MenuStrip Control</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; vertical-align: top;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Creating a MenuStrip&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; vertical-align: top;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We can create a MenuStrip control using a Forms designer at design-time or using the MenuStrip class in code at run-time or dynamically. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; vertical-align: top;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;To create a MenuStrip control at design-time, you simply drag and drop a MenuStrip control from Toolbox to a Form in Visual Studio. After you drag and drop a MenuStrip on a Form, the MenuStrip1 is added to the Form and looks like Figure 1. Once a MenuStrip is on the Form, you can add menu items and set its properties and events. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; text-align: center; vertical-align: top;&quot;&gt;&lt;shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;stroke joinstyle=&quot;miter&quot;&gt;&lt;/stroke&gt;&lt;formulas&gt;&lt;f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @0 1 0&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum 0 0 @1&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @2 1 2&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @0 0 1&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @6 1 2&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @8 21600 0&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @10 21600 0&quot;&gt;&lt;/f&gt;&lt;/formulas&gt;&lt;path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;&lt;/path&gt;&lt;lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;&lt;/lock&gt;&lt;/shapetype&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 10pt; text-align: center; vertical-align: top;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;img alt=&quot;MenuStripImg1.jpg&quot; border=&quot;0&quot; height=&quot;373px&quot; src=&quot;http://www.c-sharpcorner.com/UploadFile/mahesh/1523/Images/MenuStripImg1.jpg&quot; width=&quot;461px&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Creating a MenuStrip control at run-time is merely a work of creating an instance of MenuStrip class, set its properties and adds MenuStrip class to the Form controls. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;First step to create a dynamic MenuStrip is to create an instance of MenuStrip class. The following code snippet creates a MenuStrip control object. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;C# Code:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0pt;&quot;&gt;&lt;span style=&quot;color: #2b91af; font-family: Consolas; font-size: 9.5pt;&quot;&gt;MenuStrip&lt;/span&gt;&lt;span style=&quot;font-family: Consolas; font-size: 9.5pt;&quot;&gt; MainMenu = &lt;span style=&quot;color: blue;&quot;&gt;new &lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;MenuStrip&lt;/span&gt;();&lt;/span&gt; &lt;/div&gt;&lt;h2&gt;How to use MenuStrip Control&lt;/h2&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Drag and drop MenuStrip control from toolbox on the window Form.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image001.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image002.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;For creating menu simply add menu item in the shown textbox. Insert text in the MenuStrip which you want to display as menu.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image003.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;New and open is the sub Item of File.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image004.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image005.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Create event handlers for the above menu items as &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;New, Open, Save, Exit on the MenuStrip&lt;/b&gt; and selecting submenu items&amp;nbsp; then double click on them.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; newToolStripMenuItem_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; openToolStripMenuItem_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; saveToolStripMenuItem_Click_1(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; exitToolStripMenuItem_Click_1(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Change the Form to an MDI Form.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; frmMenuStrip_Load(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.IsMdiContainer = &lt;span style=&quot;color: blue;&quot;&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Write code on the Click event of the &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;New submenu&lt;/b&gt; item.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; newToolStripMenuItem_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;Form&lt;/span&gt; fr = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;Form&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fr.MdiParent = &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fr.Text = &lt;span style=&quot;color: #a31515;&quot;&gt;&quot;New&quot;&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;h1&gt;Run the project&lt;/h1&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image006.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;New child Form will open when New menu item clicked.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;img alt=&quot;MenuStrip Control in C#.Net&quot; src=&quot;http://www.mindstick.com/Articles/de2d8430-9539-4f0f-839f-bf17615d66e1/Images/image007.png&quot; title=&quot;MenuStrip Control&quot; /&gt; &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Write code on the Click event of the &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Open&amp;nbsp; submenu&lt;/b&gt; item.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; openToolStripMenuItem_Click(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #2b91af;&quot;&gt;OpenFileDialog&lt;/span&gt; fld = &lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #2b91af;&quot;&gt;OpenFileDialog&lt;/span&gt;();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld.ShowDialog();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Open dialog will open when Open menu item&amp;nbsp; clicked.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Write code on the Click event of &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;the Save submenu&lt;/b&gt; item.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; saveToolStripMenuItem_Click_1(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; saveFileDialog1.ShowDialog();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; line-height: 115%;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Save dialog will open when Save menu item clicked.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Write code on &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;the Click event&lt;/b&gt; of the &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Exit&lt;/b&gt;&amp;nbsp; submenu item.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; exitToolStripMenuItem_Click_1(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: #2b91af;&quot;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.Close();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/5936546162166068670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-use-menustrip-control.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/5936546162166068670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/5936546162166068670'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-use-menustrip-control.html' title='How to use MenuStrip Control'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-4426604302862881551</id><published>2011-06-09T02:07:00.000-07:00</published><updated>2011-06-16T03:50:31.230-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Dialog Controls"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How to Use OpenFileDialog Control In C# Windows Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, sans-serif; font-size: 17px; line-height: 24px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The Windows Forms platform has an excellent&amp;nbsp;&lt;b&gt;OpenFileDialog&lt;/b&gt;&amp;nbsp;control which allows you to display the standard Windows dialog box, and then you can read in the results in your C# code. Here we look at how you can use the OpenFileDialog control in Windows Forms by adding the control in Visual Studio, also opening the dialog with a button click and reading in the specified file using the C# language.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: verdana, sans-serif; font-size: 17px; line-height: 24px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-right: 300px;&quot;&gt;&lt;img alt=&quot;OpenFileDialog control in Windows&quot; height=&quot;343px&quot; id=&quot;n&quot; src=&quot;http://www.dotnetperls.com/300&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin: 0px 10px 12px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: middle;&quot; width=&quot;450px&quot; /&gt;&lt;br /&gt;
&lt;h2 style=&quot;font-size: 24px; margin: 0px 10px;&quot;&gt;Add OpenFileDialog&lt;/h2&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; First, to begin developing your OpenFileDialog, you need to open &lt;br /&gt;
your Windows Forms program in the Visual&amp;nbsp;Studio designer and open the Toolbox pane (usually on the left side of Visual Studio&#39;s window). Find the OpenFileDialog entry and double-click on it. This entry describes a control that &quot;displays a dialog box that prompts the user to open a file.&quot;&lt;/div&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;&lt;b&gt;How can I modify it?&lt;/b&gt;&amp;nbsp;You cannot modify the parts of the OpenFileDialog in the same way as other Windows Forms in the designer. Instead, you can only change properties of it in the Properties pane. To change these properties, select the &quot;openFileDialog1&quot; icon in the tray at the bottom of the Visual Studio window, and then look at the Properties pane.&lt;/div&gt;&lt;h2 style=&quot;font-size: 24px; margin: 0px 10px;&quot;&gt;Showing OpenFileDialog&lt;/h2&gt;&lt;div style=&quot;font-size: 24px; margin: 0px 10px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;Here we look at how you can open the OpenFileDialog that is in your Windows Forms program. The dialog will not open automatically and it must be invoked in your custom code. You will want to use an event handler to open the dialog in your C# code. Sometimes, using the Load event (which &quot;occurs whenever the user loads the form&quot;) is sufficient to do this. In this tutorial, we will use a button, which when clicked will open the dialog.&lt;/div&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;&lt;b&gt;Adding Button control.&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can add a Button control in Windows Forms through the Visual Studio designer that can be clicked on to call into the OpenFileDialog window. To add a Button, find the Button icon in the Toolbox and drag it to an area in your Windows Forms window. You can add an event to the button click by double-clicking on the &quot;button1&quot; in the designer.&lt;/div&gt;&lt;pre style=&quot;font-size: 15px; line-height: normal; margin: 0px 10px 12px; padding-bottom: 6px; padding-left: 0px; padding-right: 0px; padding-top: 6px;&quot;&gt;&lt;b style=&quot;background-clip: initial; background-color: gainsboro; background-origin: initial; border-bottom: rgb(255,0,255) 2px dotted; padding-bottom: 1px; padding-left: 1px; padding-right: 1px; padding-top: 1px;&quot;&gt;Program that uses OpenFileDialog [C#]&lt;/b&gt;

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication18
{
    public partial class Form1 : Form
    {
 public Form1()
 {
     InitializeComponent();
 }

 private void button1_Click(object sender, EventArgs e)
 {
     &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// Show the dialog and get result.&lt;/i&gt;
     DialogResult result = &lt;u style=&quot;font-weight: 700;&quot;&gt;openFileDialog1.ShowDialog&lt;/u&gt;();
     if (result == DialogResult.OK) &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// Test result.&lt;/i&gt;
     {
     }
     Console.WriteLine(result); &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// &amp;lt;-- For debugging use only.&lt;/i&gt;
 }
    }
}&lt;/pre&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;&lt;b&gt;Using button1_Click.&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;The above code example demonstrates the use of the openFileDialog1 component that was created in the designer in previous steps. The DialogResult enumerated type is assigned to the result of ShowDialog; this variable is then tested to see what action the user specified to take. The actual strings from the dialog window can be accessed directly as properties on openFileDialog1.&lt;/div&gt;&lt;h2 style=&quot;font-size: 24px; margin: 0px 10px;&quot;&gt;Read files&lt;/h2&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;Here we see an example of how you can access the file specified by the user in the OpenFileDialog, and then read it in using the System.IO namespace methods. We also handle exceptions, preventing some errors related to file system changes that are unavoidable. With this code, when you click on the button the dialog will ask you what file you want. When you accept the dialog, the code will read in that file and print its size in bytes.&lt;/div&gt;&lt;pre style=&quot;font-size: 15px; line-height: normal; margin: 0px 10px 12px; padding-bottom: 6px; padding-left: 0px; padding-right: 0px; padding-top: 6px;&quot;&gt;&lt;b style=&quot;background-clip: initial; background-color: gainsboro; background-origin: initial; border-bottom: rgb(255,0,255) 2px dotted; padding-bottom: 1px; padding-left: 1px; padding-right: 1px; padding-top: 1px;&quot;&gt;Program that reads in file from OpenFileDialog [C#]&lt;/b&gt;

using System;
using System.IO;
using System.Windows.Forms;

namespace WindowsFormsApplication18
{
    public partial class Form1 : Form
    {
 public Form1()
 {
     InitializeComponent();
 }

 private void button1_Click(object sender, EventArgs e)
 {
     int size = -1;
     DialogResult result = openFileDialog1.ShowDialog(); &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// Show the dialog.&lt;/i&gt;
     if (result == DialogResult.OK) &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// Test result.&lt;/i&gt;
     {
  string file = &lt;u style=&quot;font-weight: 700;&quot;&gt;openFileDialog1.FileName&lt;/u&gt;;
  try
  {
      string text = File.ReadAllText(file);
      size = text.Length;
  }
  catch (IOException)
  {
  }
     }
     Console.WriteLine(size); &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// &amp;lt;-- Shows file size in debugging mode.&lt;/i&gt;
     Console.WriteLine(result); &lt;i style=&quot;color: green; font-style: normal;&quot;&gt;// &amp;lt;-- For debugging use only.&lt;/i&gt;
 }
    }
}&lt;/pre&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;&lt;b&gt;Description of button1_Click.&lt;/b&gt;&amp;nbsp;The event handler in this program is executed when the user clicks on the button1 control. First, an OpenFileDialog as shown in the screenshot at the top of this article is displayed. Second, the DialogResult is tested for the OK value. Next, the FileName property is accessed and the file is read in with File.ReadAllText.&lt;/div&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;&lt;b&gt;How can I display the file?&lt;/b&gt;&amp;nbsp;The above program for simplicity does not have a TextBox control to display the file it opens. If you want to show the file contents in another control, add a TextBox and assign it to the result of File.ReadAllText(file), such as with &quot;textBox1.Text = text;&quot;.&lt;/div&gt;&lt;h2 style=&quot;font-size: 24px; margin: 0px 10px;&quot;&gt;Properties&lt;/h2&gt;&lt;div style=&quot;display: block; margin: 0px 10px 12px;&quot;&gt;Here we note that the OpenFileDialog control in Windows Forms has many properties that you can set directly in the designer, meaning you do not need to assign them in your own C# code. This section in this article shows some of my notes on these properties, but is not an exhaustive reference.&lt;/div&gt;&lt;a href=&quot;http://www.dotnetperls.com/environment-specialfolder&quot; style=&quot;color: #0066cc; display: block; font-weight: 700; margin: -12px 10px 12px; text-decoration: none;&quot;&gt;Environment.SpecialFolder&lt;/a&gt;&lt;a href=&quot;http://blogs.msdn.com/brandonturner/archive/2008/03/13/wow-that-s-pretty-and-easy-autoupgradeenabled-for-open-file-dialog.aspx&quot; style=&quot;color: #0066cc; display: block; font-weight: 700; margin: -12px 10px 12px; text-decoration: none;&quot;&gt;blogs.msdn.com&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;AddExtension&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;You can change this to False from its default True if you to to automatically fix file extension problems.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;AutoUpgradeEnabled&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;This allows you to auomatically get Vista-style open file dialogs. Recommended. See blogs.msdn.com link.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;CheckFileExists&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Leave this as True to give the user a warning when he selects a file that does not exist.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;CheckPathExists&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Same as CheckFileExists (see above) but for paths and directories.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;DefaultExt&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Set this to a string extension for files to automatically add that extension. This is not often useful because very few users type in their file names like this.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;DereferenceLinks&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;This tells Windows to resolve shortcuts (aliases) on the system before returning the paths. If you are writing a program that should open the shortcut file themselves, change to False.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;FileName&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;You can initialize this in the designer to a preset file name. However, this is changed to be the name the user specifies during runtime afterwards.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;Filter&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Use this to specify the file matching filter for the dialog box. The example given is &quot;C# files|*.cs&quot;, which will specify that only C# files ending with &quot;.cs&quot; should be shown.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;FilterIndex&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Use to specify the default filter, which will have index of 1. The second filter if one exists would have index of 2.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;GenerateMember&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Not OpenFileDialog specific property.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;InitialDirectory&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Specify a string here to automatically use that folder as the starting point. See more useful tips on this approach using Environment.SpecialFolder.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;Modifiers&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Not specific to this control.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;Multiselect&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Allows you to specify if multiple files can be selected at once in the dialog. Users can select multiple files by holding SHIFT or CTRL. The default is False.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;ReadOnlyChecked&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;This changes the default value of the &quot;read only&quot; checkbox, which is only shown when &quot;ShowReadOnly&quot; is set to True. (See &quot;ShowReadOnly&quot;.)&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;RestoreDirectory&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;You can set this to True to have the dialog reset its location on each use.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;ShowHelp&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Use this to enable the help button on the dialog. If your program uses the help button, you should find more information about it.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;ShowReadOnly&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Whether you want the read-only checkbox to be shown on the dialog. If you have this set to True, you can change &quot;ReadOnlyChecked&quot; to set the actual check state.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;SupportMultiDottedExtensions&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Multi-dotted extensions are extensions that have multiple dots. If you program uses multi-dotted extensions, this is useful.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;Tag&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;Not specific to this control.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;Title&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;The title of the window, such as &quot;Open File (Dot Net Perls)&quot; in the screenshot.&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px;&quot;&gt;&lt;b id=&quot;o&quot; style=&quot;background-clip: initial; background-color: yellow; background-origin: initial;&quot;&gt;ValidateNames&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;display: block; font-style: italic; margin: 0px 10px 12px 40px; text-align: left;&quot;&gt;The Windows file system does not allow files to contain characters such as &quot;*&quot;. This option should always be set to True unless your requirements are very unusual&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/4426604302862881551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-use-openfiledialog-control-in-c.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/4426604302862881551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/4426604302862881551'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-use-openfiledialog-control-in-c.html' title='How to Use OpenFileDialog Control In C# Windows Application'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-7145756109995478138</id><published>2011-06-09T02:03:00.000-07:00</published><updated>2011-06-16T03:51:10.674-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Dialog Controls"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How to handle the fontdialog in C# Windows application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Arial;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; style=&quot;width: 800px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td height=&quot;20&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The c# windows application provides the font dialog box for handling the fonts&lt;br /&gt;
&amp;nbsp;inside our project.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;img alt=&quot;Color Dialog and Font Dialog&quot; border=&quot;0&quot; src=&quot;http://www.java2s.com/Code/CSharpImages/ColorFontDialog.PNG&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;div class=&quot;codeShade&quot; style=&quot;border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(204, 204, 204); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(204, 204, 204); border-top-style: solid; border-top-width: 1px; margin-bottom: 0.5em; margin-left: 0em; margin-top: 0.5em; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px;&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f;&quot;&gt;Professional&amp;nbsp;Windows&amp;nbsp;GUI&amp;nbsp;Programming&amp;nbsp;Using&amp;nbsp;C#&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f;&quot;&gt;by&amp;nbsp;Jay&amp;nbsp;Glynn,&amp;nbsp;Csaba&amp;nbsp;Torok,&amp;nbsp;Richard&amp;nbsp;Conway,&amp;nbsp;Wahid&amp;nbsp;Choudhury,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;Zach&amp;nbsp;Greenvoss,&amp;nbsp;Shripad&amp;nbsp;Kulkarni,&amp;nbsp;Neil&amp;nbsp;Whitlow&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f;&quot;&gt;Publisher:&amp;nbsp;Peer&amp;nbsp;Information&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f;&quot;&gt;ISBN:&amp;nbsp;1861007663&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #3f7f5f;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Collections;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.ComponentModel;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Data;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;namespace&amp;nbsp;ColorFontDialog&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Summary&amp;nbsp;description&amp;nbsp;for&amp;nbsp;ColorFontDialog.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ColorFontDialog&amp;nbsp;:&amp;nbsp;System.Windows.Forms.Form&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Button&amp;nbsp;button1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Button&amp;nbsp;button2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Label&amp;nbsp;label1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Required&amp;nbsp;designer&amp;nbsp;variable.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.ComponentModel.Container&amp;nbsp;components&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ColorFontDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Required&amp;nbsp;for&amp;nbsp;Windows&amp;nbsp;Form&amp;nbsp;Designer&amp;nbsp;support&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;InitializeComponent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Font&amp;nbsp;and&amp;nbsp;Color&amp;nbsp;Dialogs&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;amp;Font&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;&amp;amp;Color&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Change&amp;nbsp;my&amp;nbsp;FONT&amp;nbsp;and&amp;nbsp;COLOR!&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;TODO:&amp;nbsp;Add&amp;nbsp;any&amp;nbsp;constructor&amp;nbsp;code&amp;nbsp;after&amp;nbsp;InitializeComponent&amp;nbsp;call&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Clean&amp;nbsp;up&amp;nbsp;any&amp;nbsp;resources&amp;nbsp;being&amp;nbsp;used.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;protected&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;override&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Dispose&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;bool&amp;nbsp;disposing&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;disposing&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;components&amp;nbsp;!=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;null&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;components.Dispose&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;base.Dispose&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;disposing&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;#region&amp;nbsp;Windows&amp;nbsp;Form&amp;nbsp;Designer&amp;nbsp;generated&amp;nbsp;code&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;Required&amp;nbsp;method&amp;nbsp;for&amp;nbsp;Designer&amp;nbsp;support&amp;nbsp;-&amp;nbsp;do&amp;nbsp;not&amp;nbsp;modify&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;the&amp;nbsp;contents&amp;nbsp;of&amp;nbsp;this&amp;nbsp;method&amp;nbsp;with&amp;nbsp;the&amp;nbsp;code&amp;nbsp;editor.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;InitializeComponent&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Button&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Button&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Label&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.SuspendLayout&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;button1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1.Location&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Point&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;button1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1.TabIndex&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;button1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1.Click&amp;nbsp;+=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.EventHandler&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1_Click_1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;button2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2.Location&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Point&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;120&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;button2&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2.TabIndex&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;button2&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2.Click&amp;nbsp;+=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.EventHandler&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2_Click&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;label1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.Location&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Point&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;48&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;label1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.Size&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;280&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;48&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.TabIndex&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;label1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;ColorFontDialog&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.AutoScaleBaseSize&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;13&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.ClientSize&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;292&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;101&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Controls.AddRange&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Control&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button2,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.button1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;})&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;ColorFontDialog&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;ColorFontDialog&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.ResumeLayout&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;false&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;#endregion&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;The&amp;nbsp;main&amp;nbsp;entry&amp;nbsp;point&amp;nbsp;for&amp;nbsp;the&amp;nbsp;application.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;///&amp;nbsp;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;STAThread&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Application.Run&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ColorFontDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button2_Click&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;object&amp;nbsp;sender,&amp;nbsp;System.EventArgs&amp;nbsp;e&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ColorDialog&amp;nbsp;cd&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ColorDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;cd.AllowFullOpen&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;allow&amp;nbsp;custom&amp;nbsp;colors&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//cd.FullOpen&amp;nbsp;=&amp;nbsp;true;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;shows&amp;nbsp;custom&amp;nbsp;colors&amp;nbsp;automatically&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;cd.Color&amp;nbsp;=&amp;nbsp;Color.DarkBlue;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;sets&amp;nbsp;the&amp;nbsp;custom&amp;nbsp;color&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//cd.Color&amp;nbsp;=&amp;nbsp;Color.Blue;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;set&amp;nbsp;the&amp;nbsp;basic&amp;nbsp;color&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;cd.ShowDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;==&amp;nbsp;System.Windows.Forms.DialogResult.OK&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.ForeColor&amp;nbsp;=&amp;nbsp;cd.Color;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1_Click_1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;object&amp;nbsp;sender,&amp;nbsp;System.EventArgs&amp;nbsp;e&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FontDialog&amp;nbsp;fd&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FontDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fd.ShowColor&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fd.Color&amp;nbsp;=&amp;nbsp;Color.Blue;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fd.ShowApply&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;ColorDialog&amp;nbsp;does&amp;nbsp;not&amp;nbsp;provide&amp;nbsp;this&amp;nbsp;option!!!&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fd.Apply&amp;nbsp;+=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;EventHandler&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ApplyFont&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fd.ShowDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!=&amp;nbsp;System.Windows.Forms.DialogResult.Cancel&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ChangeFont&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;fd&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ApplyFont&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;object&amp;nbsp;o,&amp;nbsp;EventArgs&amp;nbsp;ea&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ChangeFont&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FontDialog&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ChangeFont&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FontDialog&amp;nbsp;fd&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.Font&amp;nbsp;=&amp;nbsp;fd.Font;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;this&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.label1.ForeColor&amp;nbsp;=&amp;nbsp;fd.Color;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/7145756109995478138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-fontdialog-in-c-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7145756109995478138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/7145756109995478138'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-handle-fontdialog-in-c-windows.html' title='How to handle the fontdialog in C# Windows application'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-8903681195676650612</id><published>2011-06-08T01:22:00.003-07:00</published><updated>2011-06-16T03:46:16.761-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="Labelproperties"/><title type='text'>How Change the Label Backcolr property In asp.net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; white-space: nowrap;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;%@&amp;nbsp;Page&amp;nbsp;Language=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;C#&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;script&amp;nbsp;runat=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;page_Load&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Page.IsPostBack&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;chkIsMember.Checked==&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;true&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;lblOut.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Members&amp;nbsp;get&amp;nbsp;a&amp;nbsp;free&amp;nbsp;ticket&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;lblOut.BackColor=System.Drawing.Color.LightPink;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;if&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Convert.ToInt32&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;txtAge.Text&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;lblOut.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Students&amp;nbsp;get&amp;nbsp;a&amp;nbsp;free&amp;nbsp;ticket&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;lblOut.BackColor=System.Drawing.Color.LightPink;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;else&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;lblOut.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Price&amp;nbsp;is&amp;nbsp;500&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;lblOut.BackColor=System.Drawing.Color.LightSeaGreen;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;html&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;body&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;br&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;form&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;runat=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Please&amp;nbsp;enter&amp;nbsp;your&amp;nbsp;age&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;asp:TextBox&amp;nbsp;id=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;txtAge&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;runat=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;br&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Are&amp;nbsp;you&amp;nbsp;a&amp;nbsp;member?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;asp:CheckBox&amp;nbsp;id=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;chkIsMember&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;runat=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&amp;lt;/asp:CheckBox&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;asp:Button&amp;nbsp;id=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Button1&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;runat=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;server&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Text=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Submit&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&amp;lt;/asp:Button&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;br&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;asp:Label&amp;nbsp;id=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;lblOut&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;runat=&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;server&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;br&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;form&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;body&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;html&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/8903681195676650612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-change-label-backcolr-property-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8903681195676650612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8903681195676650612'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-change-label-backcolr-property-in.html' title='How Change the Label Backcolr property In asp.net'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-1669349541749458374</id><published>2011-06-08T01:14:00.000-07:00</published><updated>2011-06-16T03:51:56.898-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Dialog Controls"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Application"/><title type='text'>How  use the Color dialog control in C# Windows application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;img alt=&quot;Sample Image - ColorButton.gif&quot; height=&quot;240&quot; src=&quot;http://www.codeproject.com/KB/selection/ColorButton/ColorButton.gif&quot; style=&quot;overflow-x: auto; overflow-y: auto;&quot; width=&quot;336&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Arial; font-size: small; line-height: normal;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; style=&quot;width: 800px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;img alt=&quot;Set form forground color&quot; border=&quot;0&quot; src=&quot;http://www.java2s.com/Tutorial/CSharpImages/FormForegroundColorSetting.PNG&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; font-family: monospace; white-space: nowrap;&quot;&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;using&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FormForegroundColorSetting&amp;nbsp;:&amp;nbsp;System.Windows.Forms.Form&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Button&amp;nbsp;button1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.TextBox&amp;nbsp;textBox1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FormForegroundColorSetting&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Test&amp;nbsp;WinForm&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ForeColor&amp;nbsp;=&amp;nbsp;System.Drawing.Color.Yellow;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Button&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.TextBox&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;button&amp;nbsp;control&amp;nbsp;and&amp;nbsp;its&amp;nbsp;properties&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1.Location&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Point&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;button1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1.Size&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1.TabIndex&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Click&amp;nbsp;Me&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;text&amp;nbsp;box&amp;nbsp;control&amp;nbsp;and&amp;nbsp;its&amp;nbsp;properties&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1.Location&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Point&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1.Name&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;textBox1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1.Size&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Drawing.Size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;184&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1.TabIndex&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;textBox1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Adding&amp;nbsp;controls&amp;nbsp;to&amp;nbsp;the&amp;nbsp;fomr&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Controls.AddRange&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.Windows.Forms.Control&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]{&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1,&amp;nbsp;button1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1.Click&amp;nbsp;+=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.EventHandler&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1_Click&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;private&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;button1_Click&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;object&amp;nbsp;sender,System.EventArgs&amp;nbsp;e&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;textBox1.Text&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Button&amp;nbsp;is&amp;nbsp;clicked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;MessageBox.Show&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Button&amp;nbsp;is&amp;nbsp;clicked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Application.Run&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;FormForegroundColorSetting&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;return&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/1669349541749458374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-we-use-color-dialog-control-in-c.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1669349541749458374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1669349541749458374'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-we-use-color-dialog-control-in-c.html' title='How  use the Color dialog control in C# Windows application'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-1093536016484764515</id><published>2011-06-04T23:36:00.000-07:00</published><updated>2011-06-16T03:37:53.323-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="Email Transfer"/><title type='text'>How we send data through e-mail in asp.net</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;msg&quot;&gt;&lt;div class=&quot;thumb tright&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;E-MAIL IN C#&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;thumb tright&quot;&gt;&lt;/div&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;Electronic mail, commonly called email or e-mail, is a method of exchanging digital messages from an author to one or more recipients. Modern email operates across the Internet or other computer networks. Some early email systems required that the author and the recipient both be online at the same time, &lt;i&gt;a la&lt;/i&gt; instant messaging. Today&#39;s email systems are based on a store-and-forward model. Email servers accept, forward, deliver and store messages. Neither the users nor their computers are required to be online simultaneously; they need connect only&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;msg&quot;&gt;&lt;/div&gt;&lt;div class=&quot;msg&quot;&gt;&lt;span style=&quot;color: black; font-size: large;&quot;&gt;var client = new SmtpClient(&quot;smtp.gmail.com&quot;, 587)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Credentials = new NetworkCredential(TextBoxFrom.&lt;wbr&gt;&lt;/wbr&gt;Text,TextBoxpass.Text),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;EnableSsl = true&lt;br /&gt;
&amp;nbsp; &amp;nbsp;};&lt;br /&gt;
&amp;nbsp; &amp;nbsp;client.Send(TextBoxTo.Text, TextBoxTo.Text, TextBoxSubject.Text, TextBoxBody.Text);&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/1093536016484764515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-we-send-data-through-e-mail-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1093536016484764515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/1093536016484764515'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-we-send-data-through-e-mail-in.html' title='How we send data through e-mail in asp.net'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-6348026013513442464</id><published>2011-06-04T23:30:00.000-07:00</published><updated>2011-06-16T03:45:13.258-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="IIS"/><title type='text'>How we IntegratE ASP.NET  with IIS 7</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h2&gt;Introduction &lt;/h2&gt;Since its release, ASP.NET has been the platform of choice for developing Web applications on the Windows / IIS platform. ASP.NET 2.0 took Web application development to a new level,&amp;nbsp;allowing developers to&amp;nbsp;build more powerful applications faster than ever before. &lt;br /&gt;
IIS 7 takes ASP.NET&amp;nbsp;further by integrating the ASP.NET runtime extensibility model with the core server. This allows developers to fully extend the IIS 7&amp;nbsp;server with the richness of ASP.NET 2.0 and the .NET Framework, instead of using the less capable IIS C++ APIs. Existing ASP.NET applications also immediately benefit from tighter integration&amp;nbsp;by using existing ASP.NET features like Forms authentication, roles, and output caching for all&amp;nbsp;content. &lt;br /&gt;
While IIS 7 provides the improved ASP.NET integration by default, there is a choice: IIS 7 supports both the new and the old ASP.NET integration modes that can be used side by side on the same server. &lt;br /&gt;
This article discusses the improvements that are introduced by the new ASP.NET integration mode, the architecture of the two modes, and describes how to select and configure the integration modes for ASP.NET applications. &lt;br /&gt;
&lt;h2&gt;ASP.NET Enhancements on IIS 7 &lt;/h2&gt;Better ASP.NET integration in IIS 7 enhances existing applications and also allows new applications to take advantage of ASP.NET features in new ways: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;ASP.NET services can be used for all content types&lt;/b&gt;. In the past, ASP.NET functionality such as Forms authentication, roles, URL authorization, and output caching were only available to ASP.NET content types like ASPX pages. Static files, ASP pages, and other content types could not benefit from these services.&lt;/li&gt;
&lt;/ul&gt;&lt;blockquote&gt;In IIS 7, all ASP.NET services&amp;nbsp;are provided uniformly to all content. For example, you can protect all of your Web content, including images and&amp;nbsp;ASP pages, with your existing ASP.NET 2.0 access control solution built on ASP.NET Forms authentication, membership and login controls. &lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Fully extend IIS with ASP.NET.&lt;/b&gt; Previous versions of IIS frequently required server extensibility to be developed by&amp;nbsp;using the native ISAPI filter or extension extensibility mode, due to the runtime limitations of ASP.NET. &lt;/li&gt;
&lt;/ul&gt;&lt;blockquote&gt;IIS 7 allows ASP.NET modules to plug in directly into the server pipeline, with the same runtime fidelity as modules developed with the native (C++) server API. ASP.NET modules can execute in all runtime stages of the request-processing pipeline, and can be executed in any order with respect to native modules. The ASP.NET API&amp;nbsp;is also&amp;nbsp;expanded to allow more control over request processing than was previously possible. &lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Unified server runtime.&lt;/b&gt; Tighter ASP.NET integration also unifies many of the features between IIS 7&amp;nbsp;and ASP.NET.&lt;/li&gt;
&lt;/ul&gt;&lt;blockquote&gt;IIS 7 provides a unified configuration for IIS and ASP.NET modules and handlers. Many other features, including custom errors and tracing, have been unified to allow better management and cohesive application design. &lt;/blockquote&gt;&lt;h2&gt;ASP.NET Integration Architecture &lt;/h2&gt;In IIS 6.0 and previous releases, ASP.NET was implemented as an IIS ISAPI extension. &lt;br /&gt;
In these earlier releases, IIS processed&amp;nbsp;a request to an ASP.NET content type and then forwarded that request to the ASP.NET ISAPI DLL, which hosted the ASP.NET request pipeline and page framework. Requests to non-ASP.NET content, such as ASP pages or static files, were processed by IIS or other ISAPI extensions and were not visible to ASP.NET. &lt;br /&gt;
The major limitation of this model was that services provided by ASP.NET modules and custom ASP.NET application code were not available to non-ASP.NET requests. In addition, ASP.NET modules were unable to affect certain parts of the IIS request processing that occurred before and after the ASP.NET execution path. &lt;br /&gt;
&lt;a href=&quot;http://learn.iis.net/file.axd?i=151&quot; mce_href=&quot;/file.axd?i=151&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; mce_src=&quot;/file.axd?i=151&quot; src=&quot;http://learn.iis.net/file.axd?i=151&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;strong&gt;Figure 1: IIS 6.0 &amp;amp; ASP.NET Pipelines &lt;/strong&gt;&lt;br /&gt;
In IIS 7, the ASP.NET request-processing pipeline overlays the IIS pipeline directly, essentially providing a wrapper over it instead of plugging into it. &lt;br /&gt;
IIS 7 processes requests that arrive for any content type, with both native IIS modules and ASP.NET modules providing request processing in all stages. This enables services that are provided by ASP.NET modules,&amp;nbsp;such as&amp;nbsp;Forms authentication or output cache, to be used for requests to ASP pages, PHP pages, static files, and so on. &lt;br /&gt;
The ability to plug in directly into the server pipeline allows ASP.NET modules to replace, run before, or run after any IIS 7&amp;nbsp;functionality. This enables, for example, a custom ASP.NET Basic authentication module that is written to use the Membership service and SQL Server user database to replace the built-in IIS Basic authentication feature that works only with Windows accounts. &lt;br /&gt;
In addition, the expanded ASP.NET APIs use direct integration to enable more request-processing tasks. For example, ASP.NET modules can modify request headers before other components process the request, by inserting an Accept-Language header before ASP applications execute, which&amp;nbsp;forces localized content to be sent back to the client based on user preference. &lt;br /&gt;
&lt;a href=&quot;http://learn.iis.net/file.axd?i=152&quot; mce_href=&quot;/file.axd?i=152&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; mce_src=&quot;/file.axd?i=152&quot; src=&quot;http://learn.iis.net/file.axd?i=152&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;strong&gt;Figure 2: IIS 7 Integrated Mode &lt;/strong&gt;&lt;br /&gt;
Because of the runtime integration, IIS 7&amp;nbsp;and ASP.NET can use the same configuration to enable and order server modules, and to configure handler mappings. Other unified functionality includes tracing, custom errors, and output caching. &lt;br /&gt;
&lt;h2&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;migrating&quot; title=&quot;migrating&quot;&gt;&lt;/a&gt;Compatibility &lt;/h2&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;migrating&quot; title=&quot;migrating&quot;&gt;&lt;/a&gt;Most notably, the architecture maintains the ASP.NET runtime architecture and APIs, which allows existing ASP.NET applications and services to work upon installation. With a few modifications, the existing ASP.NET applications and services&amp;nbsp;can take advantage of the new ASP.NET capabilities. &lt;br /&gt;
Likewise, developers can continue to write new applications to familiar ASP.NET APIs while they harness the benefits of the runtime integration. &lt;br /&gt;
IIS 7 continues to provide the Classic ASP.NET mode for ASP.NET applications that have specific compatibility requirements that are not met by the Integrated mode. Administrators can select the desired integration mode per application pool, which lets applications that use both the new and the Classic ASP.NET modes to function side-by-side on the same server. &lt;br /&gt;
&lt;h2&gt;Migrating ASP.NET Applications to IIS 7 Integrated Mode &lt;/h2&gt;On IIS 7, ASP.NET is configured to operate in the new Integrated mode by default. This lets your application take advantage of Integrated mode enhancements with minimal modifications. &lt;br /&gt;
Because of the configuration unification, some applications may require migration&amp;nbsp;to operate properly in Integrated mode. By default, the server provides assistance with migration. It detects applications that require migration, and returns an error message requesting that you migrate the application. &lt;br /&gt;
The following configuration causes the migration error: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;strong&gt;The application Web.config file defines &amp;lt;httpModules&amp;gt; configuration.&lt;/strong&gt;&lt;br /&gt;
The application loads new ASP.NET modules or removes existing ones. &lt;br /&gt;
In Integrated mode, ASP.NET modules are specified with native modules in the unified &amp;lt;system.webServer&amp;gt;/&amp;lt;modules&amp;gt; configuration section.&lt;br /&gt;
The ASP.NET modules that are specified in the &amp;lt;system.web&amp;gt;/&amp;lt;httpModules&amp;gt; configuration section&amp;nbsp;must be moved to the new configuration section&amp;nbsp;to take effect. Subsequently, new ASP.NET modules&amp;nbsp;must be added directly to the unified &amp;lt;modules&amp;gt; section. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The application Web.config file defines &amp;lt;httpHandlers&amp;gt; configuration.&lt;/strong&gt;&lt;br /&gt;
The application uses custom handler mappings for some content types. &lt;br /&gt;
In Integrated mode, ASP.NET handler mappings&amp;nbsp;must be specified in the unified &amp;lt;system.webServer&amp;gt;/&amp;lt;handlers&amp;gt; configuration section&amp;nbsp;to take effect. Subsequently, new ASP.NET handler mappings&amp;nbsp;must be added directly to the unified &amp;lt;handlers&amp;gt; section.&lt;br /&gt;
This section replaces both the ASP.NET &amp;lt;httpHandlers&amp;gt; configuration and the IIS 7&amp;nbsp;scriptmaps configuration, both of which previously had to be configured to set up an ASP.NET handler mapping. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The application Web.config file defines &amp;lt;identity impersonate=&quot;true&quot; /&amp;gt; configuration.&lt;/strong&gt;&lt;br /&gt;
The application impersonates client credentials, which is&amp;nbsp;most common with intranet applications. In Integrated mode, client impersonation is not available in some early request-processing stages. In the majority of cases, this is not a problem and you can turn off the migration error.&amp;nbsp;Otherwise, you&amp;nbsp;must configure this application to run by using the Classic ASP.NET mode. &lt;/li&gt;
&lt;/ol&gt;When the migration&amp;nbsp;error is generated, it can generally either migrate the application configuration (recommended in cases 1 and 2, above), or move the application to use Classic ASP.NET mode (in case 3). &lt;br /&gt;
&lt;h2&gt;Migrating the Application Configuration &lt;/h2&gt;IIS 7 migrates the application by using the AppCmd.exe command line tool to perform the migration. The migration error message contains the command that&amp;nbsp;is executed in the command line window, which you must run with administrator user rights,&amp;nbsp;to instantly migrate your application to Integrated mode. &lt;br /&gt;
The basic format of the migration command is as follows: &lt;br /&gt;
&lt;samp&gt;%windir%\system32\inetsrv\APPCMD.EXE migrate config &amp;lt;Application Path&amp;gt;&lt;/samp&gt; &lt;br /&gt;
&lt;div mce_keep=&quot;true&quot;&gt;Where &amp;lt;Application Path&amp;gt; is the virtual path of the application that contains the site name, such as &quot;Default Web Site/app1&quot;. &lt;/div&gt;When the migration is complete, your application will run in both Integrated and Classic modes without any problems. &lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt; If you change the configuration after migration, the server will not prompt you to migrate again. After the&amp;nbsp;initial migration, you&amp;nbsp;must make sure that your configuration remains in sync between the two modes. You can manually migrate the application again by using the AppCmd.exe command line tool. &lt;br /&gt;
&lt;h2&gt;Moving Back to Classic ASP.NET Integration Mode &lt;/h2&gt;If you would rather return to the Classic ASP.NET mode, move your application to an application pool that is configured to run in Classic mode. Other applications continue to run in the new Integrated mode side-by-side with the Classic mode application. &lt;br /&gt;
For more information about how to move an application to the Classic ASP.NET mode, see Changing ASP.NET Modes for an Application. &lt;br /&gt;
&lt;h2&gt;Disabling the Migration Error Message &lt;/h2&gt;If you have manually migrated your configuration or want to remain in Integrated mode without migrating your configuration (not recommended), you can disable the migration error message by adding the following to&amp;nbsp;the application&#39;s Web.config file: &lt;br /&gt;
&lt;samp&gt;&amp;lt;system.webServer&amp;gt; &lt;br /&gt;
&amp;lt;validation validateIntegratedModeConfiguration=&quot;false&quot; /&amp;gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;lt;/system.webServer&amp;gt;&lt;/samp&gt; &lt;br /&gt;
&lt;strong&gt;Note&lt;/strong&gt;: The server automatically disables the error message after migrating the configuration with the AppCmd.exe command line tool. &lt;br /&gt;
If you manually disable the migration error message, you must make sure that your application works properly in Integrated mode,&amp;nbsp;because the server will no longer provide any warnings&amp;nbsp;about the unsupported configuration. &lt;br /&gt;
&lt;h2&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;Changing ASP.NET Modes for an Application &lt;/h2&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;If your application does not work properly in Integrated ASP.NET mode, you can move it to the Classic ASP.NET mode by moving it to another application pool. Each application pool is individually configured to use the desired ASP.NET integration mode. This&amp;nbsp;lets you run groups of applications that use&amp;nbsp;different ASP.NET integration modes side-by-side on the same server. &lt;br /&gt;
&lt;strong&gt;To change the ASP.NET integration mode for an application:&lt;/strong&gt; &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;Find or create an application pool that is configured to use the desired mode.&lt;/strong&gt; &lt;br /&gt;
By default, all new application pools run in Integrated mode.&lt;br /&gt;
The ASP.NET set up provides an application pool named &quot;&lt;strong&gt;Classic .NET AppPool&lt;/strong&gt;&quot; that runs in the classic ASP.NET integration mode. You can use this application pool for applications that should not run in Integrated mode.&lt;br /&gt;
You can also change the ASP.NET mode of the existing application pool by&amp;nbsp;using the IIS 7 Administration Tool&amp;nbsp;or the&amp;nbsp;AppCmd.exe command line tool, or by&amp;nbsp;manually editing the application pool configuration. &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;Set the application to use that application pool.&lt;/strong&gt; &lt;br /&gt;
Each application is configured to use a particular application pool. By default, all applications use the default application pool named &quot;&lt;strong&gt;DefaultAppPool&lt;/strong&gt;&quot;, which runs in Integrated mode.&lt;br /&gt;
You can change the application pool of an application by using the IIS 7 Administration Tool or&amp;nbsp;the&amp;nbsp;AppCmd.exe command line tool, or by manually editing the application configuration. &lt;/li&gt;
&lt;/ol&gt;&lt;h2&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;Selecting an ASP.NET Version for an Application &lt;/h2&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;Historically, IIS has supported multiple versions of ASP.NET / CLR side-by-side. For example,&amp;nbsp;IIS allows&amp;nbsp;the same server to run ASP.NET applications by using .NET Framework v1.1 and v2.0. This support was provided by mapping a corresponding version of ASPNET_isapi.dll to serve requests for the ASP.NET content by using the IIS 7&amp;nbsp;scriptmaps configuration. &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;For example, you&amp;nbsp;can use&amp;nbsp;the following scriptmap configuration to enable side-by-side support: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;ASP.NET v1.1 application on /app1:&lt;/strong&gt;&lt;br /&gt;
*.aspx -&amp;gt; d:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;ASP.NET v2.0 application on /app2:&lt;/strong&gt;&lt;br /&gt;
*.aspx -&amp;gt; d:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll &lt;/li&gt;
&lt;/ol&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;When the application receives&amp;nbsp;a *.aspx request, IIS 7&amp;nbsp;loads the specified aspnet_isapi.dll, which loads the correct CLR version into the worker process, and processes the request. &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;ASP.NET also provides the following ways to configure side-by-side scriptmaps: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;ASP.NET MMC extension.&lt;/strong&gt;&amp;nbsp;When you&amp;nbsp;pick the version of ASP.NET to use,&amp;nbsp;the extension automatically configures the scriptmaps for the application to point to the correct version of aspnet_isapi.dll. &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;ASP.NET aspnet_regiis.exe.&lt;/strong&gt;&amp;nbsp;Use the –i and –r options to install the scriptmaps that point to the corresponding ASP.NET version. &lt;/li&gt;
&lt;/ol&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;Unfortunately, due to the limitation of&amp;nbsp;the ability&amp;nbsp;to load only&amp;nbsp;one CLR version into a single worker process,&amp;nbsp;you&amp;nbsp;must make sure that&amp;nbsp;two applications that use different versions&amp;nbsp;of ASP.NET are never configured to exist within the same application pool. When this common mistake is made, the first request loads the CLR of the corresponding aspnet_isapi.dll, and subsequent requests to the other version within the same application pool will fail. &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;IIS 7 recognizes that the application pool is the ASP.NET version that you select to run an application under. As such, the version of the CLR / ASP.NET that is loaded in the application pool is explicitly configured in the application pool configuration. By default, IIS 7&amp;nbsp;pre-loads the CLR that is specified by this setting when loading the worker process (unless the version is configured to be empty). &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;Because application pools are the .NET Framework versioning boundary, you can change the version of an ASP.NET application by doing the following: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;Move the application to an application pool that uses the desired ASP.NET version.&lt;/strong&gt; &lt;br /&gt;
By default, applications use the default application pool named &quot;DefaultAppPool,&quot; which runs ASP.NET v2.1 in Integrated mode. Move the application to the &quot;Classic .NET AppPool&quot; to run in ASP.NET v2.1 Classic mode, or another application pool of your choice. &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;Configure the application pool within which the application is running to use the desired ASP.NET version.&lt;/strong&gt; &lt;br /&gt;
By default, all new application pools&amp;nbsp;are configured to run ASP.NET v2.1 in Integrated mode. &lt;/li&gt;
&lt;/ol&gt;&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;&lt;strong&gt;Note:&lt;/strong&gt; Do not use aspnet_regiis /i or /r options to configure the version of ASP.NET for a particular application, or globally. &lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=3464107191210707975&amp;amp;postID=6348026013513442464&amp;amp;from=pencil&quot; name=&quot;changemode&quot; title=&quot;changemode&quot;&gt;&lt;/a&gt;IIS 7 uses pre-conditioned handler mappings to automatically select the correct set of handler mappings (to ASPNET_isapi.dll in Classic mode or directly to managed handler types in Integrated mode) depending on the configured CLR version and managed integration mode of the application pool. The ASP.NET 2.0 setup installs these handler mappings at the server level. &lt;br /&gt;
&lt;h2&gt;Taking Advantage of Integrated ASP.NET Mode &lt;/h2&gt;On IIS 7, ASP.NET applications run in Integrated mode by default. However, to take advantage of the benefits that are provided by tighter integration, you&amp;nbsp;must make some modifications to the application configuration. You can also develop new ASP.NET components that take advantage of the Integrated mode to provide powerful functionality to your application. &lt;br /&gt;
&lt;h2&gt;Enabling ASP.NET Services for All Types of Content &lt;/h2&gt;In Integrated mode, services that are&amp;nbsp;provided by ASP.NET modules are available to requests for all content types. However, by default, ASP.NET modules are configured to execute only for requests to ASP.NET content for backward compatibility. &lt;br /&gt;
To do this,&amp;nbsp;attach a managedHandler precondition to each ASP.NET module in the configuration section at the server level: &lt;br /&gt;
&lt;div&gt;&lt;samp&gt;&amp;lt;modules&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name=&quot;FormsAuthentication&quot; type=&quot;System.Web.Security.FormsAuthenticationModule&quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;preCondition=&quot;managedHandler&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name=&quot;UrlAuthorization&quot; type=&quot;System.Web.Security.UrlAuthorizationModule&quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;preCondition=&quot;managedHandler&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;
&amp;lt;/modules&amp;gt;&lt;/samp&gt; &lt;br /&gt;
&lt;div mce_keep=&quot;true&quot;&gt;The precondition is a rule that the server evaluates&amp;nbsp;on every request to determine whether a module will be executed. The managedHandler precondition is only true for requests to content types that are&amp;nbsp;mapped to ASP.NET handlers. &lt;/div&gt;To apply functionality that is&amp;nbsp;provided by an ASP.NET module to all requests, remove the module entry, and then&amp;nbsp;re-add it without the precondition in&amp;nbsp;the application&#39;s root Web.config file. &lt;br /&gt;
To enable ASP.NET Forms authentication for the entire application, modify your Web.config file as follows: &lt;br /&gt;
&lt;samp&gt;&amp;lt;modules&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;remove name=&quot;FormsAuthentication&quot; /&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;add name=&quot;FormsAuthentication&quot; type=&quot;System.Web.Security.FormsAuthenticationModule&quot; /&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;…&lt;br /&gt;
&amp;lt;/modules&amp;gt;&lt;/samp&gt;With this change, the FormsAuthentication module executes for all requests in your application. This lets you&amp;nbsp;protect all of the application content with Forms authentication. For more information about how to leverage the Integrated mode to provide Forms authentication for all application content, see &lt;a href=&quot;http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis7-integrated-pipeline/&quot; mce_href=&quot;http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis7-integrated-pipeline/&quot;&gt;&lt;span style=&quot;color: #118bd8;&quot;&gt;Taking Advantage of Integrated&amp;nbsp;Pipeline Mode&amp;nbsp;walkthrough&lt;/span&gt;&lt;/a&gt;. &lt;br /&gt;
You can also use a shortcut to enable all managed (ASP.NET) modules to run for all requests in your application, regardless of the &quot;managedHandler&quot; precondition. To enable all managed modules to run for all requests without configuring each module entry to remove the &quot;managedHandler&quot; precondition, use the &lt;strong&gt;runAllManagedModulesForAllRequests&lt;/strong&gt; property in the &amp;lt;modules&amp;gt; section: &lt;br /&gt;
&lt;div&gt;&lt;samp&gt;&amp;lt;modules runAllManagedModulesForAllRequests=&quot;true&quot; /&amp;gt;&amp;nbsp;&lt;/samp&gt;&lt;/div&gt;When you use this, the &quot;managedHandler&quot; precondition has no effect and all managed modules will run for all requests. &lt;br /&gt;
Experiment with enabling other ASP.NET modules to apply to your entire application. For example, use the ASP.NET Output Cache module to output cache ASP pages, or use URL Authorization and Role Manager to configure access control rules for your photos. Or, develop your own module to bring the power of ASP.NET to your entire Web site. &lt;br /&gt;
&lt;h2&gt;Building More Powerful ASP.NET Services &lt;/h2&gt;In Integrated mode, ASP.NET modules apply their services to all content. In addition, because ASP.NET modules execute in the unified request-processing pipeline in Integrated mode, they subscribe to the same request-processing stages and perform the same tasks as native server modules. At the same time, ASP.NET APIs remain largely the same, with a few key additions that unlock previously unavailable functionality. &lt;br /&gt;
&lt;h2&gt;Runtime Fidelity &lt;/h2&gt;In Integrated mode, the ASP.NET request-processing stages that are exposed to modules are directly connected to the corresponding stages of the IIS 7&amp;nbsp;pipeline. The complete pipeline contains the following stages, which are exposed as HttpApplication events in ASP.NET: &lt;br /&gt;
&lt;div&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;BeginRequest&lt;/strong&gt;. The request processing starts. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AuthenticateRequest&lt;/strong&gt;. The request is authenticated. IIS 7&amp;nbsp;and ASP.NET authentication modules subscribe to this stage to perform authentication. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostAuthenticateRequest&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AuthorizeRequest&lt;/strong&gt;. The request is authorized. IIS 7&amp;nbsp;and ASP.NET authorization modules check whether the authenticated user has access to the resource requested. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostAuthorizeRequest&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ResolveRequestCache&lt;/strong&gt;. Cache modules check whether the response to this request exists in the cache, and return it instead of proceeding with the rest of the execution path. Both ASP.NET Output Cache and IIS 7&amp;nbsp;Output Cache features execute. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostResolveRequestCache&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MapRequestHandler&lt;/strong&gt;. This stage is internal in ASP.NET and is used to determine the request handler. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostMapRequestHandler&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AcquireRequestState&lt;/strong&gt;. The state necessary for the request execution is retrieved. ASP.NET Session State and Profile modules obtain their data. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostAcquireRequestState&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PreExecuteRequestHandler&lt;/strong&gt;. Any tasks before the execution of the handler&amp;nbsp;are performed. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ExecuteRequestHandler&lt;/strong&gt;. The request handler executes. ASPX pages, ASP pages, CGI programs, and static files are served. &lt;/li&gt;
&lt;li&gt;PostExecuteRequestHandler &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ReleaseRequestState&lt;/strong&gt;. The request state changes are saved, and the state is cleaned up here. ASP.NET Session State and Profile modules use this stage for cleanup. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostReleaseRequestState&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;UpdateRequestCache&lt;/strong&gt;. The response&amp;nbsp;is stored in the cache for future use. The ASP.NET Output Cache and IIS 7&amp;nbsp;Output Cache modules execute to save the response to their caches. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostUpdateRequestCache&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LogRequest&lt;/strong&gt;. This stage logs the results of the request, and is guaranteed to execute even if errors occur. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PostLogRequest&lt;/strong&gt;. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;EndRequest&lt;/strong&gt;. This stage performs any final request cleanup, and is guaranteed to execute even if errors occur. &lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;By using the familiar ASP.NET APIs, the ability to execute in the same stages as IIS 7 modules&amp;nbsp;makes tasks that were only previously accessible in native ISAPI filters and extensions now possible in managed code. &amp;nbsp;For example, you can now write modules that do the following: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Intercept the request before any processing has taken place, for example rewriting URLs or performing security filtering. &lt;/li&gt;
&lt;li&gt;Replace built-in authentication modes. &lt;/li&gt;
&lt;li&gt;Modify the incoming request contents, such as request headers. &lt;/li&gt;
&lt;li&gt;Filter outgoing responses for all content types. &lt;/li&gt;
&lt;/ol&gt;See &lt;a href=&quot;http://learn.iis.net/page.aspx/366/developing-iis7-modules-and-handlers-with-the-net-framework/&quot; mce_href=&quot;http://learn.iis.net/page.aspx/366/developing-iis7-modules-and-handlers-with-the-net-framework/&quot;&gt;&lt;span style=&quot;color: #118bd8;&quot;&gt;Developing an IIS 7 Module with .NET&lt;/span&gt;&lt;/a&gt;&amp;nbsp;for&amp;nbsp;a good example of how to extend IIS 7&amp;nbsp;with a custom ASP.NET authentication module.&lt;br /&gt;
&lt;h2&gt;Expanded ASP.NET APIs &lt;/h2&gt;The ASP.NET APIs remain backward compatible with previous releases, which allows existing modules to work in IIS 7 without modification, and to apply to all application content without code changes. &lt;br /&gt;
However, modules that are written for IIS 7 Integrated mode can take advantage of a few additional APIs to enable key request-processing scenarios that were not previously available. &lt;br /&gt;
The new &lt;strong&gt;HttpResponse.Headers&lt;/strong&gt; collection allows modules to inspect and manipulate response headers that other application components generate. For example, you can change the Content-Type header that is generated by an ASP page to prompt a download dialog box in the browser. The Cookies collection on the HttpResponse class&amp;nbsp;is also&amp;nbsp;enhanced to allow modification of cookies that are generated as part of the request processing, even if they were created outside of ASP.NET. &lt;br /&gt;
The &lt;strong&gt;HttpRequest.Headers&lt;/strong&gt; collection is write-enabled, which allows modules to manipulate the incoming request headers.&amp;nbsp;Use this&amp;nbsp;to change the behavior of other server components – for example, you can force a localized application to respond to the client in a different language by dynamically changing the value of the Accept-Language header. &lt;br /&gt;
Finally, the &lt;strong&gt;HttpRequest.ServerVariables&lt;/strong&gt; collection is now writeable, which allows IIS 7&amp;nbsp;server variables to be set. ASP.NET modules use this functionality to change values that are provided by&amp;nbsp;IIS 7, and to create new server variables that are visible to other application frameworks, like PHP. &lt;br /&gt;
&lt;h2&gt;Runtime Integration &lt;/h2&gt;In addition to the new APIs, Integrated mode enables existing ASP.NET functionality to provide more value to your application. &lt;br /&gt;
The tracing facilities that are provided by ASP.NET, including the System.Diagnostics.Trace class and the ASP.NET page tracing feature, now emit trace information into the IIS 7&amp;nbsp;trace system. This enables the trace information that is generated during request processing by both IIS 7&amp;nbsp;and ASP.NET components to be placed in a single log file, facilitating better diagnostics of server issues. &lt;br /&gt;
The ASP.NET response-filtering feature, which allows responses to be changed by using a Stream interface before it goes to the client,&amp;nbsp;is enhanced to allow filtering of non-ASP.NET content. Therefore, you can use ASP.NET filtering&amp;nbsp;on all server content, or selectively install the filter only for requests to content that you&amp;nbsp;want to process. With this capability, you can write filtering features that inject or censor certain content in&amp;nbsp;the site&#39;s responses, regardless of whether this content comes from an ASPX page or a static file. &lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/6348026013513442464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-we-integrate-aspnet-with-iis-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/6348026013513442464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/6348026013513442464'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-we-integrate-aspnet-with-iis-7.html' title='How we IntegratE ASP.NET  with IIS 7'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3464107191210707975.post-8231246920674502339</id><published>2011-06-04T05:05:00.000-07:00</published><updated>2011-06-16T03:52:42.230-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp"/><category scheme="http://www.blogger.com/atom/ns#" term="Grid views"/><title type='text'>How to format GridView Rows/Columns in Design/Run time</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;em&gt;&lt;span style=&quot;color: #cc33cc;&quot;&gt;&lt;span style=&quot;color: #000099;&quot;&gt;&lt;/span&gt; How to format date/numeric data in GridView in design time&lt;br /&gt;
&lt;span style=&quot;color: #000099;&quot;&gt;&lt;/span&gt;How to format data in GridView in run time/code behind&lt;br /&gt;
&lt;span style=&quot;color: #000099;&quot;&gt;&lt;/span&gt;How to format Template Column&lt;br /&gt;
&lt;span style=&quot;color: #000099;&quot;&gt;&lt;/span&gt;How to use DataFormatString property to format data&lt;br /&gt;
&lt;span style=&quot;color: #000099;&quot;&gt;&lt;/span&gt; What is HtmlEncode?&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div align=&quot;justify&quot;&gt;&lt;br /&gt;
Consider we have a  GridView that displays Supplier information with Code, Name, Address,  Contact no and Supply date where the Supply date is stored with time in  database. To do that for bound column apply the below technique:&lt;/div&gt;&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&amp;lt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;BoundField&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;DataField&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;LastDelivery&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;HeaderText&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;Recent Delivery&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;DataFormatString&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&quot;{0:y}&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;HtmlEncode&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;false&quot;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;BoundField&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
OR&lt;br /&gt;
&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&amp;lt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;BoundField&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;DataField&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;LastDelivery&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;HeaderText&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;Recent Delivery&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;DataFormatString&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&quot;{0:MMMM yyyy}&quot;&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red; font-size: 85%;&quot;&gt;HtmlEncode&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;false&quot;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon; font-size: 85%;&quot;&gt;BoundField&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
If you want to format date using SQL query then &lt;a href=&quot;http://shawpnendu.blogspot.com/2009/04/sql-server-date-time-format.html&quot;&gt;Click Here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
i.e. You can use both format or pattern column to format date column like below:&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH1TC_AnJmBsZak26Fab1Dp9UcZKWaHaHH2GxqS7JAv9hoVpK5DiJ1_SH6EIMQ6rbwOi5DwEuGI_R_Er5PHo5s2nBZlrl1NsSLWQeydGMOYu8DZq0S8zNNloa_Mrp9YsbKdBNq_AvTtnE/s1600-h/dateformat1.JPG&quot;&gt;&lt;br /&gt;
&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5323475292804843954&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH1TC_AnJmBsZak26Fab1Dp9UcZKWaHaHH2GxqS7JAv9hoVpK5DiJ1_SH6EIMQ6rbwOi5DwEuGI_R_Er5PHo5s2nBZlrl1NsSLWQeydGMOYu8DZq0S8zNNloa_Mrp9YsbKdBNq_AvTtnE/s400/dateformat1.JPG&quot; style=&quot;cursor: hand; height: 99px; width: 400px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
Formatting columnar data in a GridView code-behind:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; gvEdit_RowDataBound(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: teal;&quot;&gt;GridViewRowEventArgs&lt;/span&gt; e)&lt;br /&gt;
{&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (e.Row.RowType == &lt;span style=&quot;color: teal;&quot;&gt;DataControlRowType&lt;/span&gt;.DataRow)&lt;br /&gt;
{e.Row.Cells[4].Text = &lt;span style=&quot;color: teal;&quot;&gt;Convert&lt;/span&gt;.ToDateTime(((&lt;span style=&quot;color: teal;&quot;&gt;DataRowView&lt;/span&gt;)e.Row.DataItem)[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;LastDelivery&quot;&lt;/span&gt;]).ToString(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;y&quot;&lt;/span&gt;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Format Template Column:&lt;/span&gt;Add a template column with textbox/label etc.. then format it in the below way:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;TemplateField&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;HeaderText&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;Recent Delivery&quot;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;ItemTemplate&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;Label&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;lbl&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;Text&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&#39;&lt;/span&gt;&amp;lt;%# Eval(&quot;LastDelivery&quot;, &quot;{0:y}&quot;) %&amp;gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;Label&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;ItemTemplate&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;TemplateField&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
List of Numeric Formats:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;2&quot; style=&quot;border-collapse: collapse;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;Format&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;Description&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;Example&lt;/span&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;C&lt;/td&gt;&lt;td&gt;Currency format&lt;/td&gt;&lt;td&gt;$10.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;D&lt;/td&gt;&lt;td&gt;Decimal format&lt;/td&gt;&lt;td&gt;10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;E&lt;/td&gt;&lt;td&gt;Scientific format&lt;/td&gt;&lt;td&gt;1.000000E+001&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;F&lt;/td&gt;&lt;td&gt;Fixed format&lt;/td&gt;&lt;td&gt;10.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;G&lt;/td&gt;&lt;td&gt;General format&lt;/td&gt;&lt;td&gt;10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;N&lt;/td&gt;&lt;td&gt;Number format&lt;/td&gt;&lt;td&gt;10.00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;X&lt;/td&gt;&lt;td&gt;Hexadecimal format&lt;/td&gt;&lt;td&gt;A&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;div align=&quot;justify&quot;&gt;&lt;span style=&quot;color: #ff6600;&quot;&gt;Note: Format characters are not case-sensitive, except for &quot;X&quot;&lt;/span&gt;&lt;br /&gt;
The  value after the format character specifies the number of significant  digits or decimal places to display. For example, the formatting string  &quot;{0:F2}&quot; displays a fixed-point number with two decimal places.&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
Format numeric data in bound column:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;BoundField&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;DataField&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;Price&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;HeaderText&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;Price&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;DataFormatString&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;{0:C2}&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;HtmlEncode&lt;/span&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;=&quot;false&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Format numeric data in Template Column:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;TemplateField&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;HeaderText&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;Recent Delivery&quot;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;ItemTemplate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;Label&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;ID&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;lbl&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;runat&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;server&quot;&lt;/span&gt; &lt;span style=&quot;color: red;&quot;&gt;Text&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&#39;&lt;/span&gt;&amp;lt;%# Eval(&quot;Price&quot;, &quot;{0:C2}&quot;) %&amp;gt;&lt;span style=&quot;color: blue;&quot;&gt;&#39;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;Label&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;ItemTemplate&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;asp&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: maroon;&quot;&gt;TemplateField&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Formatting columnar data in a GridView code-behind:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;border-bottom: silver 1px ridge; border-left: silver 1px ridge; border-right: silver 1px ridge; border-top: silver 1px ridge; overflow: hidden; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 550px;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;color: blue; font-size: 85%;&quot;&gt;&lt;span style=&quot;font-size: 180%;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; gvEdit_RowDataBound(&lt;span style=&quot;color: blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color: teal;&quot;&gt;GridViewRowEventArgs&lt;/span&gt; e)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (e.Row.RowType == &lt;span style=&quot;color: teal;&quot;&gt;DataControlRowType&lt;/span&gt;.DataRow)&lt;br /&gt;
((&lt;span style=&quot;color: teal;&quot;&gt;Label&lt;/span&gt;)e.Row.FindControl(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;lbl&quot;&lt;/span&gt;)).Text = &lt;span style=&quot;color: teal;&quot;&gt;Convert&lt;/span&gt;.ToDecimal(((&lt;span style=&quot;color: teal;&quot;&gt;DataRowView&lt;/span&gt;)e.Row.DataItem)[&lt;span style=&quot;color: maroon;&quot;&gt;&quot;ID&quot;&lt;/span&gt;]).ToString(&lt;span style=&quot;color: maroon;&quot;&gt;&quot;C5&quot;&lt;/span&gt;);&lt;br /&gt;
}&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGV8ZhS4xqsITCzhwZG9sk6L8TDJIeWpU6VzJSzUwTjm_Mf2UsNoAe0DcNcP93rf76Xn-31cXKGTD_cQuAslqbTb3eyD9NhMhW10Vi7kUnvbN0CNb0lvbwMLTieoBnGeF81LPMbBecd0M/s1600-h/SimpleNumeric.JPG&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5323473855467216226&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGV8ZhS4xqsITCzhwZG9sk6L8TDJIeWpU6VzJSzUwTjm_Mf2UsNoAe0DcNcP93rf76Xn-31cXKGTD_cQuAslqbTb3eyD9NhMhW10Vi7kUnvbN0CNb0lvbwMLTieoBnGeF81LPMbBecd0M/s400/SimpleNumeric.JPG&quot; style=&quot;cursor: hand; height: 155px; width: 90px;&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;div align=&quot;justify&quot;&gt;You may need to add few prefix like AU/US then use :&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;em&gt;DataFormatString=&quot;AU {0:C5}&quot; HtmlEncode=&quot;false&quot;&lt;/em&gt;&lt;/span&gt;OR&lt;br /&gt;
&lt;span style=&quot;font-size: 85%;&quot;&gt;&lt;em&gt;DataFormatString=&quot;US {0:C5}&quot; HtmlEncode=&quot;false&quot;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2LgYmKrUYATawOIoTRBHtY3uT0u9MhKWzQy2l6wagwLfjHT-UECKkvk0GnQrnr1-5uuDfqdKcdgdfEdKjlL0d9Cx-ON12jHiXourYPjrl_YoNYPBwehVavx-xjZZiwlHm34y39tVlUJE/s1600-h/AUNumeric.JPG&quot;&gt;&lt;strong&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5323474415378426066&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2LgYmKrUYATawOIoTRBHtY3uT0u9MhKWzQy2l6wagwLfjHT-UECKkvk0GnQrnr1-5uuDfqdKcdgdfEdKjlL0d9Cx-ON12jHiXourYPjrl_YoNYPBwehVavx-xjZZiwlHm34y39tVlUJE/s400/AUNumeric.JPG&quot; style=&quot;cursor: hand; height: 156px; width: 109px;&quot; /&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;br /&gt;
&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeaspprogramming.blogspot.com/feeds/8231246920674502339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-format-gridview-rowscolumns-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8231246920674502339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3464107191210707975/posts/default/8231246920674502339'/><link rel='alternate' type='text/html' href='http://codeaspprogramming.blogspot.com/2011/06/how-to-format-gridview-rowscolumns-in.html' title='How to format GridView Rows/Columns in Design/Run time'/><author><name>Rafeek</name><uri>http://www.blogger.com/profile/07644393944565459149</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5B9aQVLC5SVY0cM88mtGEyUv4ty4w3Mm_AywsV95cZ9wLPhXjm9iAvi5rMNhO-4ZByREtUIxcv3d-9XOZFvlnoe6UFpYA0JqoA5nhPIkLwX8RygkKL05-ru8D-YERxo/s220/rafeeque.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH1TC_AnJmBsZak26Fab1Dp9UcZKWaHaHH2GxqS7JAv9hoVpK5DiJ1_SH6EIMQ6rbwOi5DwEuGI_R_Er5PHo5s2nBZlrl1NsSLWQeydGMOYu8DZq0S8zNNloa_Mrp9YsbKdBNq_AvTtnE/s72-c/dateformat1.JPG" height="72" width="72"/><thr:total>0</thr:total></entry></feed>