tag:blogger.com,1999:blog-71764988285669018742024-03-13T20:11:54.853-07:00S.VinothkumarHello and Welcome! Most of the articles at this site were created in response to questions, comments, or arguments put forth by people who challenge the pre tribulation rapture.Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.comBlogger148125tag:blogger.com,1999:blog-7176498828566901874.post-78917445554918998812013-07-04T15:19:00.002-07:002013-07-04T15:19:33.925-07:00Take ASP.NET application to offline<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;">Hi All,</span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;">Here is a simple way to bring asp.net application down.</span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;">Just create a htm file named "<strong>app_offline.htm</strong>" and place it in your root directory. All request to your website will redirect to that app_offline.htm page automatically. If you keep some text like "Site under maintenance" or if you have some nice information to say the customer that the site is in under construction / maintenance it can be easily conveyed. Once your maintenance work completed, you can just remove that file.</span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;">It is not actually a redirect but, ASP.NET essentially shuts down the site, unloads it from the
server, and stops processing any requests to your site. Once you
delete the app_offline.htm file then everything will work fine and your
ASP.NET site will load up and start serving requests.</span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="color: #ffe599; font-family: Arial, Helvetica, sans-serif;">However, you have to keep in mind one thing that you should have enough content in that file (more than 512 bytes) or IE will consider it as 404 then you will see 404 error message.</span><br />
<br />
<br />
<br />
</div>
Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com2tag:blogger.com,1999:blog-7176498828566901874.post-6464247265109851342010-07-23T00:47:00.000-07:002010-07-23T00:51:14.510-07:00Difference between DataGrid and GridView<span style="color:#ccffff;">Hi All !<br /><br />I am back !!!</span><br /><br /><span style="color:#ffffcc;"><strong>Difference between DataGrid and GridView:<br />========================================== </strong></span><br /><br /><span style="color:#ffffff;">In .Net 2.0, we are using GridView. Since DataGrid and GridView are same we have some extra facilities and features in GridView than DataGrid.<br /><br />By using GridView we can render it on Mobile Devices also, but DataGrid only use for web pages. Another key difference between DataGrid and GridView controls lies in the adaptive user interface.<br /><br />In DataGrid paging, sorting, inserting, updating and deleting are implementing by coding. But in GridView automatically generates those things without user writing the code.<br />Sorting: In DataGrid code requires handling the SortCommand event and rebind grid required. In case of GridView no additional code required.<br />Paging: In DataGrid requires code to handle the PageIndexChanged event and rebind grid required. In case of GridView no additional code required. It also supports customized appearance.<br />Data binding: Like GridView DataGrid cannot bind with new datasource control in ASP.NET 2.0.<br />Updating data: DataGrid requires extensive code to update operation on data. GridView requires little code. Code like exceptions handling for database part.<br />Events: GridView supports events fired before and after database updates. In DataGrid fewer events supported as compared to GridView.<br /><br />In DataGrid no image template column, whereas GridView have image template column<br />The GridView control is the successor to the DataGrid control. Like the DataGrid control, the GridView control was designed to display data in an HTML table. When bound to a data source, the DataGrid and GridView controls each display a row from a DataSource as a row in an output table.<br /><br />Both the DataGrid and GridView controls are derived from the WebControl class. Although it has a similar object model to that of the DataGrid control, the GridView control also has a number of new features and advantages over the DataGrid control, which include:<br /><br />Richer design-time capabilities.<br /><br />Improved data source binding capabilities.<br /><br />Automatic handling of sorting, paging, updates, and deletes.<br /><br />Additional column types and design-time column operations.<br /><br />A Customized pager user interface (UI) with the PagerTemplate property.<br /><br />Differences between the GridView control and the DataGrid control include:<br /><br />Different custom-paging support.<br /><br />Different event models.</span><br /><br /><br /><strong><span style="color:#330000;">...S.VinothkumaR.</span></strong>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com17tag:blogger.com,1999:blog-7176498828566901874.post-75270272427510306652009-09-03T03:40:00.000-07:002009-09-03T03:44:50.723-07:00How to clear temporary internet foder by using C# in winforms?Here is the sample code for clearing temporary internet foder by using C# in winforms.<br /><br /> <span style="color: rgb(255, 255, 204);">private void btnClear_Click(object sender, EventArgs e)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> ClearAll(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));</span><br /><span style="color: rgb(255, 255, 204);"> MessageBox.Show("Your temporary files has been cleaned.! ");</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><br /><span style="color: rgb(255, 255, 204);"> public void ClearAll(DirectoryInfo dirInfo)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> foreach (FileInfo fileInfo in dirInfo.GetFiles())</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> try</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> fileInfo.Delete();</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> catch { }</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> foreach (DirectoryInfo subDirectory in dirInfo.GetDirectories())</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> ClearAll(subDirectory);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinotkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com4tag:blogger.com,1999:blog-7176498828566901874.post-69093359666899223522009-08-19T03:16:00.000-07:002009-08-19T03:19:30.097-07:00How to insert bulk values in to a table by using C#?The below method is used to bulk insert in to a table by using c# from a datatable.<br /><br /><span style="color: rgb(255, 255, 204);">using System.Data;</span><br /><span style="color: rgb(255, 255, 204);">using System.Data.SqlClient;</span><br /><br /><span style="color: rgb(255, 255, 204);">public int BulkInsert(DataTable dt, string TableName, string ConnectionString)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> int returnValue = -1;</span><br /><span style="color: rgb(255, 255, 204);"> SqlConnection oConn = new SqlConnection(ConnectionString);</span><br /><span style="color: rgb(255, 255, 204);"> oConn.Open();</span><br /><span style="color: rgb(255, 255, 204);"> SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM " + TableName,oConn);</span><br /><span style="color: rgb(255, 255, 204);"> da.SelectCommand.Connection = oConn;</span><br /><span style="color: rgb(255, 255, 204);"> DataSet ds = new DataSet();</span><br /><span style="color: rgb(255, 255, 204);"> SqlCommandBuilder oCmd = new SqlCommandBuilder(da);</span><br /><span style="color: rgb(255, 255, 204);"> try</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> da.Fill(ds);</span><br /><span style="color: rgb(255, 255, 204);"> returnValue = da.Update(dt);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> catch (Exception ex)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> throw ex;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> finally</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> oConn.Close();</span><br /><span style="color: rgb(255, 255, 204);"> oCmd.Dispose();</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> return returnValue;</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com2tag:blogger.com,1999:blog-7176498828566901874.post-40718693951364155222009-08-19T03:03:00.000-07:002009-08-19T03:06:32.203-07:00Copy All Directories with Files using C#Here is the sample code for copying a directory with sub directories and all the files using C#.<br /><br /><br /><span style="color: rgb(255, 255, 204);">public static void CopyAllDirectories(DirectoryInfo source, DirectoryInfo target)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> if (Directory.Exists(target.FullName) == false)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> Directory.CreateDirectory(target.FullName);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><br /><span style="color: rgb(255, 255, 204);"> foreach (FileInfo fileInfo in source.GetFiles())</span><br /><span style="color: rgb(255, 255, 204);"> { fileInfo.CopyTo(Path.Combine(target.ToString(),fileInfo.Name), true);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> foreach (DirectoryInfo sourceSubDir in source.GetDirectories())</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> DirectoryInfo targetSubDir =</span><br /><span style="color: rgb(255, 255, 204);"> target.CreateSubdirectory(sourceSubDir.Name);</span><br /><span style="color: rgb(255, 255, 204);"> CopyAllDirectories (sourceSubDir, targetSubDir);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-30522601816492774452009-08-03T06:05:00.000-07:002009-08-03T06:14:29.692-07:00Scrollbar in down side of textbox.<span style="font-weight: bold; color: rgb(255, 255, 255);">Scrollbar in down side of textbox.</span><br /><br />Hi all, I have come to give a very simple solution for the below question. The question is<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">How to set scrollbar in end of the text in textbox when dynamically updating the text value?</span><br /><br />Actually I have been developing a big application. On that application I needed to update the status of every action in my application. For the purpose of updating the status, I have used the textbox to show the status with <span style="font-weight: bold;">multiline </span>and <span style="font-weight: bold;">vertical scrollbar</span> properties. But I could see the vertical bar not going down when updating the status as shown in the below figure which is marked in red.<br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFbHH6bcWDamEkJ-Qm8btqPY1EVwI5k_IuMfyf6ASv2-aD_E76_Omg4wq1C8gE0x8EAhORN4HB7jtMfW-XKUth5nx5CIBiCaPmeUwlWrLNgyX72bJRtB8pyi8XTRoGY32XLt_cURQGSGg/s1600-h/scrolldown1.JPG"><img style="cursor: pointer; width: 301px; height: 301px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFbHH6bcWDamEkJ-Qm8btqPY1EVwI5k_IuMfyf6ASv2-aD_E76_Omg4wq1C8gE0x8EAhORN4HB7jtMfW-XKUth5nx5CIBiCaPmeUwlWrLNgyX72bJRtB8pyi8XTRoGY32XLt_cURQGSGg/s320/scrolldown1.JPG" alt="" id="BLOGGER_PHOTO_ID_5365723252097588178" border="0" /></a><br /><br />After googling few minutes I found we have some properties and methods in textboxes of visual studio are <span style="font-weight: bold;">SelectionStart </span>and <span style="font-weight: bold;">ScrollToCaret </span>method.<br /><br />By using the above property and method I have found the solution for my question. See the below figure...<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTbzvLIsIPMMk4an1-BzHN6NOmFjRXKvVOd0B__i4avd9JducuPHP3cMjkvKjXpkjx9YBsA4z7dGUk2Ew0qh0uTptNTdOp9GFu6_7XxW6aAZlyDl-UzumPkl7yP1A15IdULloL7NSLWe4/s1600-h/scrolldown2.JPG"><img style="cursor: pointer; width: 299px; height: 301px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTbzvLIsIPMMk4an1-BzHN6NOmFjRXKvVOd0B__i4avd9JducuPHP3cMjkvKjXpkjx9YBsA4z7dGUk2Ew0qh0uTptNTdOp9GFu6_7XxW6aAZlyDl-UzumPkl7yP1A15IdULloL7NSLWe4/s320/scrolldown2.JPG" alt="" id="BLOGGER_PHOTO_ID_5365723338060189810" border="0" /></a><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Code Snippet:</span><br /><br /><span style="color: rgb(255, 255, 204);">private void btnUpdate_Click(object sender, EventArgs e)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> if (!string.IsNullOrEmpty(txtStatus.Text))</span><br /><span style="color: rgb(255, 255, 204);"> txtStatus.Text = txtStatus.Text + Environment.NewLine;</span><br /><span style="color: rgb(255, 255, 204);"> txtStatus.Text = txtStatus.Text + "Status Updated...";</span><br /><br /><span style="color: rgb(255, 255, 204);"> txtStatus.SelectionStart = txtStatus.Text.Length;</span><br /><span style="color: rgb(255, 255, 204);"> txtStatus.ScrollToCaret();</span><br /><span style="color: rgb(255, 255, 204);"> txtStatus.Refresh();</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com3tag:blogger.com,1999:blog-7176498828566901874.post-43460436463543682612009-07-29T23:42:00.000-07:002009-07-29T23:45:41.276-07:00Barcode Generation using C#In this article, I am trying to give you a sample code for generating barcode image by using C#.<br /><br />We can see in market for all products they are using barcode only. So the barcode is common one. When we try to programming with old language for barcode is very difficult. We needed to go third party component. But in .Net framework it is very easy to generate barcode image.<br /><br /><span style="font-weight: bold;">Barcode font</span><br /><br />There is lot of free barcode fonts available in internet. We can search and download it for generating the barcode image. Here is the font which is I am using “Barcodefont.ttf”. We need to download this font and install in your fonts folder which is located in control panel.<br /><br />For generating barcode image, we need to add the namespaces “System.Drawing, System.Drawing.Imaging” and the file management namespaces.<br /><br /><span style="font-weight: bold;">Sample Code</span><br /><br /><span style="color: rgb(255, 255, 204);">using System.Drawing.Text;</span><br /><span style="color: rgb(255, 255, 204);">using System.Drawing;</span><br /><span style="color: rgb(255, 255, 204);">using System.IO;</span><br /><span style="color: rgb(255, 255, 204);">using System.Drawing.Imaging;</span><br /><br /><span style="color: rgb(255, 255, 204);">public string dirPath = "";</span><br /><br /><span style="color: rgb(255, 255, 204);">dirPath = Environment.CurrentDirectory;</span><br /><br /><span style="color: rgb(255, 255, 204);">private void GenerateBarCode()</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> try</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> string path = dirPath + "\\" + DateTime.Now.ToFileTimeUtc().ToString() + ".jpg";</span><br /><span style="color: rgb(255, 255, 204);"> PrivateFontCollection fontCollection = new PrivateFontCollection();</span><br /><span style="color: rgb(255, 255, 204);"> fontCollection.AddFontFile(dirPath + "\\BarcodeFont.ttf");</span><br /><span style="color: rgb(255, 255, 204);"> FontFamily fontFamily = new FontFamily("barcode font", fontCollection);</span><br /><span style="color: rgb(255, 255, 204);"> Font font = new Font(fontFamily, 40);</span><br /><br /><span style="color: rgb(255, 255, 204);"> Bitmap bmp = new Bitmap(pbBarcodeImage.Width, pbBarcodeImage.Height);</span><br /><span style="color: rgb(255, 255, 204);"> Graphics graphics = Graphics.FromImage(bmp);</span><br /><span style="color: rgb(255, 255, 204);"> graphics.Clear(Color.White);</span><br /><span style="color: rgb(255, 255, 204);"> SizeF sizeF = graphics.MeasureString(txtEnter.Text.Trim(), font);</span><br /><span style="color: rgb(255, 255, 204);"> Brush brush = new SolidBrush(Color.Black);</span><br /><span style="color: rgb(255, 255, 204);"> graphics.DrawString(txtEnter.Text.Trim(), font, brush, 10, 10);</span><br /><span style="color: rgb(255, 255, 204);"> bmp.Save(path, ImageFormat.Jpeg);</span><br /><span style="color: rgb(255, 255, 204);"> bmp.Dispose();</span><br /><span style="color: rgb(255, 255, 204);"> pbBarcodeImage.Image = new Bitmap(path);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> catch</span><br /><span style="color: rgb(255, 255, 204);"> { }</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br />Hence we are generating the barcode by using the above code.<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com2tag:blogger.com,1999:blog-7176498828566901874.post-44518819487870916862009-07-01T03:07:00.000-07:002009-07-01T03:13:27.177-07:00Inserting Bulk Data in SQL Server from Text fileThere is a simple query to do this bulk insert in to sql server from a text file. The thing is that we have to keep a fully formatted text file with appropriate data’s which are to be inserted.<br /><br />Here, we have a table to be inserted is,<br /><br />The query for creating table,<br /><br /><span style="color: rgb(255, 255, 204);">CREATE TABLE Employee</span><br /><span style="color: rgb(255, 255, 204);">(</span><br /><span style="color: rgb(255, 255, 204);"> FName varchar (100) NOT NULL,</span><br /><span style="color: rgb(255, 255, 204);"> LName varchar (100) NOT NULL,</span><br /><span style="color: rgb(255, 255, 204);"> Email varchar (100) NOT NULL</span><br /><span style="color: rgb(255, 255, 204);">)</span><br /><br />Then we have a text file with the bulk data’s like as follows,<br /><br /><span style="color: rgb(255, 255, 255);">vinoth,kumar,itvinoth83@gmail.com</span><br /><span style="color: rgb(255, 255, 255);">emp1FName,emp1LName,emp1@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp2FName,emp2LName,emp2@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp3FName,emp3LName,emp3@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp4FName,emp4LName,emp4@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp5FName,emp5LName,emp5@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp6FName,emp6LName,emp6@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp7FName,emp7LName,emp7@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp8FName,emp8LName,emp8@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp9FName,emp9LName,emp9@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp10FName,emp10LName,emp10@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp11FName,emp11LName,emp11@company.com</span><br /><span style="color: rgb(255, 255, 255);">emp12FName,emp12LName,emp12@company.com</span><br /><br />Now the query for inserting bulk data is,<br /><br /><span style="color: rgb(255, 255, 204);">BULK INSERT Employee FROM 'c:\bulktext.txt' WITH (FIELDTERMINATOR = ',')</span><br /><br />Now you can see the data's inserted in table by the select query as follows,<br /><br /><span style="color: rgb(255, 255, 204);">select * from Employee</span><br /><br />The following image is being explained the above matters.<br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTKEWwBxzb_eK9LZnhUXvCq9qbKo3EmS5rUu2Ei0DHFMu_wGFzmZsls0bmODgxHN3oId9nLE7fbz7ZpJzoQVvnpCOcxo5GipGOzMDJOoD_iMHrXGgE_nugjvDL92gyA7gMDzZD6x4DOcQ/s1600-h/bulkinsert.JPG"><img style="cursor: pointer; width: 320px; height: 254px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTKEWwBxzb_eK9LZnhUXvCq9qbKo3EmS5rUu2Ei0DHFMu_wGFzmZsls0bmODgxHN3oId9nLE7fbz7ZpJzoQVvnpCOcxo5GipGOzMDJOoD_iMHrXGgE_nugjvDL92gyA7gMDzZD6x4DOcQ/s320/bulkinsert.JPG" alt="" id="BLOGGER_PHOTO_ID_5353431650126373618" border="0" /></a><br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com3tag:blogger.com,1999:blog-7176498828566901874.post-80602416650291341552009-06-27T00:26:00.000-07:002009-06-27T00:33:08.146-07:00Multiple Colored texts in RichTextBox using C#<div style="text-align: justify;">This article is created for making multiple colored texts in a textbox. By using the SelectionText property in richtextbox we have created a sample application for multiple colored texts in Microsoft’s richtextbox control. Let us see how to make it in below code.<br /></div><br /><br /> <span style="color: rgb(255, 255, 204);"> Font font = new Font("Tahoma", 8, FontStyle.Regular);</span><br /><span style="color: rgb(255, 255, 204);"> richTextBox1.SelectionFont = font;</span><br /><span style="color: rgb(255, 255, 204);"> richTextBox1.SelectionColor = Color.Red;</span><br /><span style="color: rgb(255, 255, 204);"> richTextBox1.SelectedText = Environment.NewLine + textBox1.Text;</span><br /><br /><br /><div style="text-align: justify;">By using the above code, we can make a multiple colored texts in our richtextbox. This is basically used for doing some chat application. We will have to show the other end of person’s text in different color in chat application. So that we can use this method. And we can create a simple method and calling in every time of showing the text in richtextbox with the parameters of like “textbox1.text, color,..etc”.<br /></div><br />For more visit my article in codeproject <a href="http://www.codeproject.com/KB/cs/MultiColored_textbox.aspx">here </a>with more explanation.<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com1tag:blogger.com,1999:blog-7176498828566901874.post-46413442262765838902009-06-19T22:39:00.000-07:002009-06-19T23:05:29.977-07:00How to sum previous rows value SqlServer?<span style="font-size:85%;">
<br /></span><meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Csvinoth%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >I needed to write a query for sum the values with the previous row value in </span><span style=";font-family:Verdana;font-size:85%;" >current row of a column. So that I have written a singl</span><span style=";font-family:Verdana;font-size:85%;" >e query after a long googled. Here I am trying to give yo</span><span style=";font-family:Verdana;font-size:85%;" >u what I have done.</span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >I have a table with three fields Id, Name and </span><span style=";font-family:Verdana;font-size:85%;" >Mark. I have values of all fields like as follows.
<br /></span><span style="font-size:85%;">
<br /></span><span style=";font-family:Verdana;font-size:85%;" >Id Name Mark
<br />--- ----- -----</span>
<br /><span style=";font-family:Verdana;font-size:85%;" >1 aaaa 10
<br />2 bbbb 20
<br />3 cccc 30
<br /></span><span style="font-size:85%;">
<br /></span><span style=";font-family:Verdana;font-size:85%;" >Now I wants to get the results set of that table like as</span><span style="font-size:85%;">
<br /></span><span style=";font-family:Verdana;font-size:85%;" >
<br />Id Name Mark
<br />--- ----- -----</span><span style="font-size:85%;">
<br /></span><span style=";font-family:Verdana;font-size:85%;" >1 aaaa 10
<br />2 bbbb 30</span><span style="font-size:85%;">
<br /></span><span style=";font-family:Verdana;font-size:85%;" >3 cccc 60
<br />
<br />So I need a single select query to do this performance. For that I have written a query using cross join.</span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p style="font-weight: bold;" class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >Code Snippets for Table and Query</span></p><p style="font-weight: bold;" class="MsoNormal"><span style="font-size:85%;">
<br /></span></p><p style="font-weight: bold; color: rgb(255, 255, 204);" class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" ><span style="font-weight: normal;">CREATE TABLE [dbo].[Marks](</span> <span style="font-weight: normal;"> [Id] [bigint] NOT NULL,</span> <span style="font-weight: normal;"> [Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,</span> <span style="font-weight: normal;"> [Mark] [bigint] NOT NULL</span> <span style="font-weight: normal;">) ON [PRIMARY]</span> <span style="font-weight: normal;"> </span> <span style="font-weight: normal;">
<br /></span></span></p><p style="font-weight: bold; color: rgb(255, 255, 204);" class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" ><span style="font-weight: normal;">
<br /></span></span></p><p style="font-weight: bold; color: rgb(255, 255, 204);" class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" ><span style="font-weight: normal;">select * from Marks</span></span></p><p style="font-weight: bold;" class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p class="MsoNormal"><span style="font-size:85%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibkQnRgKR5f6t1M9XmiA9Y0nxzF6VP1OxKAGAYusbllu_RBBiZxxgIjIztcYZihyphenhyphenhxHNi5H7hHvmNU_ZnyTxLSgcIzyInfF43pp3ecIXy-H3D5BzNArD527F3Qf5TdPYttY3bH-btcNx0/s1600-h/mark1.JPG"><img style="cursor: pointer; width: 130px; height: 78px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibkQnRgKR5f6t1M9XmiA9Y0nxzF6VP1OxKAGAYusbllu_RBBiZxxgIjIztcYZihyphenhyphenhxHNi5H7hHvmNU_ZnyTxLSgcIzyInfF43pp3ecIXy-H3D5BzNArD527F3Qf5TdPYttY3bH-btcNx0/s320/mark1.JPG" alt="" id="BLOGGER_PHOTO_ID_5349285300655965474" border="0" /></a></span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p style="color: rgb(255, 255, 204);" class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >select a.Id, a.Name, sum(b.Mark) as Mark
<br />from Marks a cross join Marks b
<br />where b.Id <= a.Id group by a.Id, a.Name</span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p class="MsoNormal"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsSf5NGVX3JipBg_BqOV7RuYfe1yuwCg4SXKXwXv97j6tAuG9yWJQKvSzW81boJGpSEolWqA3pCGSzgamjrS8gaqtxvO1OSHLcutiJkjVKAO3Oq7EiIAM06Fi0ZJwxCFVAlKKhLXmURZk/s1600-h/mark2.JPG"><img style="cursor: pointer; width: 130px; height: 78px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsSf5NGVX3JipBg_BqOV7RuYfe1yuwCg4SXKXwXv97j6tAuG9yWJQKvSzW81boJGpSEolWqA3pCGSzgamjrS8gaqtxvO1OSHLcutiJkjVKAO3Oq7EiIAM06Fi0ZJwxCFVAlKKhLXmURZk/s320/mark2.JPG" alt="" id="BLOGGER_PHOTO_ID_5349286117863393330" border="0" /></a></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >Hence we have done the fetching the result set for sum of the previous rows in sql server.</span></p><p class="MsoNormal"><span style="font-size:85%;">
<br /></span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >For more ...</span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >
<br /></span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" >visit <a href="http://www.codeproject.com/KB/database/sum_previous_rows.aspx">here</a></span></p><p class="MsoNormal"><span style="font-size:85%;">
<br /></span></p><p class="MsoNormal"><span style=";font-family:Verdana;font-size:85%;" ><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>
<br /></span></p><p class="MsoNormal"><span style="font-size:85%;">
<br /></span><span style=";font-family:Verdana;font-size:85%;" ><o:p></o:p></span></p> Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com1tag:blogger.com,1999:blog-7176498828566901874.post-91923209976332669052009-06-16T03:53:00.000-07:002009-06-16T04:02:49.320-07:00Multiple rows in a single row with separator in SqlServer<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Csvinoth%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->
<br />Here is a simple way to make a single row value from multiple rows with a separator in SqlServer.
<br />
<br />
<br />I have a table like the following…
<br />
<br />Table Name: People
<br />
<br /><span style="color: rgb(255, 255, 204);">select * from people</span>
<br />
<br />
<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-7MoPEA_N4zp4OsV6ZIBhzcWeVl3NztLVDhBY_Dj-8R70FEV40TBCAcorSazE5NADrei5vRICoVRVWIG9fTi8OS1qgTgyg03CZhNq1DJWcbUQqSt_sPhPdPnyBAT4PTbcsiFDvOC4grw/s1600-h/tblPeoplt.JPG"><img style="cursor: pointer; width: 243px; height: 292px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-7MoPEA_N4zp4OsV6ZIBhzcWeVl3NztLVDhBY_Dj-8R70FEV40TBCAcorSazE5NADrei5vRICoVRVWIG9fTi8OS1qgTgyg03CZhNq1DJWcbUQqSt_sPhPdPnyBAT4PTbcsiFDvOC4grw/s320/tblPeoplt.JPG" alt="" id="BLOGGER_PHOTO_ID_5347877355511322450" border="0" /></a>
<br /><meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Csvinoth%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><p class="MsoNormal">
<br /></p><p class="MsoNormal">Now I need the ‘Name’ column values where matching the value of ‘aaaa’ in to a single row. For this I have tried to make a query.
<br />
<br />Just use the following query to get the solution.
<br />
<br /><span style="color: rgb(255, 255, 204);">declare @res varchar(1000) </span>
<br /><span style="color: rgb(255, 255, 204);">select @res = coalesce(@res + ',', '') +Name</span>
<br /><span style="color: rgb(255, 255, 204);"> from people</span>
<br /><span style="color: rgb(255, 255, 204);"> WHERE Name = 'aaaa' </span>
<br />
<br /><span style="color: rgb(255, 255, 204);">select @res</span>
<br />
<br /></p><p class="MsoNormal">See the result…</p><p class="MsoNormal">
<br /></p><p class="MsoNormal">
<br /></p><p class="MsoNormal"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQtT-d8rH95qU9QrhPqqgtXNnIGwPX9BCkworJfEAceF-4ei_tLmnxi6JEtF-_zlRIPZ_c_Nj4JmvyGeLNM6mB-mf44I2IbOIeWZS4A11s_q4a6uGsFLX6wZHYWs29Av792r-q8Rsv0R8/s1600-h/ans.JPG"><img style="cursor: pointer; width: 187px; height: 65px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQtT-d8rH95qU9QrhPqqgtXNnIGwPX9BCkworJfEAceF-4ei_tLmnxi6JEtF-_zlRIPZ_c_Nj4JmvyGeLNM6mB-mf44I2IbOIeWZS4A11s_q4a6uGsFLX6wZHYWs29Av792r-q8Rsv0R8/s320/ans.JPG" alt="" id="BLOGGER_PHOTO_ID_5347877508549022114" border="0" /></a>
<br /><span style=";font-family:";font-size:10;" ><o:p></o:p></span></p>
<br />
<br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>
<br /><span style=";font-family:Verdana;font-size:10;" ><o:p></o:p></span><p></p> Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-84550177295535751522009-06-11T05:29:00.001-07:002009-06-11T05:33:46.703-07:00Simple recursive function for string folding in C#Here is the sample function of string folding in c#. I just tried bind the body content of a mail in to a label box. For that I need to folding the string content. I have created a method to do this string folding as follows,<br /><br /> <span style="color: rgb(255, 255, 204);"> if (lblBody.Text.Length > 150)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> lblBody.Text = lblbodystring(lblBody.Text,150);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><br /><span style="color: rgb(204, 204, 204);">//Simple recursive function for string folding. </span><br /><span style="color: rgb(255, 255, 204);">private string lblbodystring(string bodyString, int Length)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> string retVal = "";</span><br /><span style="color: rgb(255, 255, 204);"> if (bodyString.Length > Length)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> retVal = bodyString.Substring(0, Length);</span><br /><span style="color: rgb(255, 255, 204);"> retVal = retVal + Environment.NewLine;</span><br /><span style="color: rgb(255, 255, 204);"> retVal = retVal + lblbodystring(bodyString.Substring(Length));</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> else</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> retVal = retVal + Environment.NewLine;</span><br /><span style="color: rgb(255, 255, 204);"> retVal = retVal + bodyString;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> return retVal;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><br /><br />The thing is that we can use textbox with multiline attribute for this kind of process :). But I have used in label. So...<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-49560267479666226702009-06-11T04:25:00.000-07:002009-06-11T05:28:05.134-07:00Query for importing data’s from XL to SqlServer DBHere is a simple query for importing data's from Microsoft Excel sheet to Sql Server database.<br /><br />Just copy the following code and run in your sql server query window. Before that make XL sheet with the appropriate fields and values and place it in c drive or wherever you wants.<br /><br /><span style="color: rgb(255, 255, 204);">INSERT INTO [dbo].[TableName] ([FieldName1]</span> <span style="color: rgb(255, 255, 204);"> ,[FieldName2]</span> <span style="color: rgb(255, 255, 204);"> ,[FieldName3]</span> <span style="color: rgb(255, 255, 204);"> ,[FieldName4]</span> <span style="color: rgb(255, 255, 204);">FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',</span> <span style="color: rgb(255, 255, 204);">'Data Source=C:\db.xls;Extended Properties=Excel 8.0')...[SheetName$]</span><br /><br />that's it...<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-14743904937120973542009-06-11T03:46:00.000-07:002009-06-11T03:49:28.260-07:00Silverlight - IntroductionMicrosoft Silverlight is a programmable web browser plug-in that enables features such as animation, vector graphics and audio-video playback that characterizes rich Internet applications.<br /><br /><div style="text-align: justify;">Silverlight provides a retained mode graphics system similar to Windows Presentation Foundation, and integrates multimedia, graphics, animations and interactivity into a single runtime environment. In Silverlight applications, user interfaces are declared in XAML and programmed using a subset of the .NET Framework. XAML can be used for marking up the vector graphics and animations. Textual content created with Silverlight is searchable and indexable by search engines as it is not compiled, but represented as text (XAML).<br /></div><br /><span style="color: rgb(255, 255, 255); font-weight: bold;">Releases</span><br /><br />1. Silverlight 1.0<br />2. Silverlight 2<br />3. Silverlight 3<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Tools for Silverlight application</span><br /><br />To developing Silverlight application, Microsoft has been released some set of tools. They are,<br /><br />• Visual Studio 2008 with Service Pack 1<br />• Silverlight 2 Beta 2 SDK<br />• Expression Blend 2 July 2008 Preview<br /><br />All of us known about Visual Studio. Expression Blend is Microsoft's user interface design tool for creating graphical interfaces for web and desktop applications. Blend is writing using the .NET Framework 3.0 and Windows Presentation Foundation (WPF). Microsoft Expression Blend does the same of Adobe Photoshop to edit your images as well as add effects to existing images.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">How to create Silverlight applications? </span><br /><br />There is a question in our mind raising that “How to create Silverlight applications?” Here is the answer for your question,<br /><br />1. Use Visual Studio 2008 SP1 to create a new Silverlight project based on the Silverlight 2 Beta 2 Template. Visual Studio will do the necessary steps to add a single HTML page or a single website to host your Silverlight application. This is because Silverlight is a plug-in that renders in the browser.<br /><br />2. Add your necessary XAML files needed for the user interface. This is similar to the forms that you would add to a Windows Form application.<br /><br />3. Edit the XAML page using Expression Blend 2 July 2008 preview. Note that Because each page in Silverlight 2 Beta 2 is treated as a user control, only Expression Blend 2 July 2008 preview will be capable of opening these particular XAML files. Any older version of Expression Blend will throw an error message saying that it is unable to open that file type.<br /><br />4. Switch to Visual Studio 2008 SP1 to write code behind files for the controls and pages that you created in Step 2.<br /><br />5. Build and compile the application.<br /><br />6. Host the same in IIS or any web server of your choice. For this demonstration, you will rely on Windows Vista for development and IIS for hosting the application.<br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-5669268883561396252009-06-11T03:35:00.000-07:002009-06-11T03:45:32.974-07:00Simple Collapse Panel - Windows application in C#Hi all, There is no option to collapsing functionality in panel control.<span style="line-height: 115%;font-family:Calibri;font-size:11;" ></span>
<br />
<br />I have created a panel control with up/down arrow images. We can collapse this control by clicking those arrows. There are some property values allowing us the interval of collapsing time. The <span style="font-weight: bold;">ScrollInterval</span> value is used to set the interval time for collapsing animation. And the <span style="font-weight: bold;">HeaderHeight</span> property value is set to be the height of header part in this control. I just used some calculation to set the height value for this control in a certain loop. This much of calculation makes some animation to collapsing the control.
<br />
<br />You can see the magic of this control by downloading the demo project which is available to download <a href="http://www.codeproject.com/KB/cs/CollapsePanel.aspx">here</a>.
<br />
<br />The simple calculation of control’s height is possible to collapse the control. Just see the following code,
<br />
<br /><span style="color: rgb(255, 255, 204);">if (this.Height > this.lblTop.Height)</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> while (this.Height > this.lblTop.Height)</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> Application.DoEvents();</span>
<br /><span style="color: rgb(255, 255, 204);"> this.Height -= ScrollIntervalValue;</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br /><span style="color: rgb(255, 255, 204);"> this.lblTop.ImageIndex = 1;</span>
<br /><span style="color: rgb(255, 255, 204);"> this.Height = this.lblTop.Height;</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br /><span style="color: rgb(255, 255, 204);"> else if (this.Height == this.lblTop.Height)</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> int x = this.FixedHeight;</span>
<br /><span style="color: rgb(255, 255, 204);"> while (this.Height <= (x))</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> Application.DoEvents();</span>
<br /><span style="color: rgb(255, 255, 204);"> this.Height += ScrollIntervalValue;</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br /><span style="color: rgb(255, 255, 204);"> this.lblTop.ImageIndex = 0;</span>
<br /><span style="color: rgb(255, 255, 204);"> this.Height = x;</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br />
<br /> Just refer the control in your application, and add the control in your form. Then set the property values of this control ScrollInterval and HeaderHeight as you want. If you don’t set those property values it might be taken by default values. Now build your project and run. By clicking the arrow images in collapse panel, you can see the magic.
<br />
<br />For More…see my article in code project.
<br />
<br /><a href="http://www.codeproject.com/KB/cs/CollapsePanel.aspx">http://www.codeproject.com/KB/cs/CollapsePanel.aspx</a>
<br />
<br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>
<br />
<br /><meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Csvinoth%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Calibri; mso-font-alt:Arial; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:Calibri; mso-fareast-font-family:"Times New Roman"; mso-bidi-font-family:"Times New Roman";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->
<br />Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-76993556173354262602009-06-03T00:41:00.000-07:002009-06-03T00:45:18.473-07:00How do we change the header BackColor and selected color in ListView using c#?<span style="font-weight: bold;">How do we change the header BackColor and selected color in ListView using c#?</span><br /><br />Yes, we can make it possible to change the header backcolor and style for ListView control. And also we can change the some styles in ListView control in the code behind. Here is the way to explain how it is possible.<br /><br />There is property named “<span style="font-weight: bold; color: rgb(255, 255, 255);">OwnerDraw</span>” is used to do the style changing process by our code behind. Just we need to set that property as “true”.<br /><br />I have a ListView control with the name of “<span style="font-weight: bold;">lstView</span>” in my sample form, and the code has been written as follows,<br /><br /><span style="color: rgb(255, 255, 204);">this.lstView.BackColor = System.Drawing.SystemColors.ControlText;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.BorderStyle = System.Windows.Forms.BorderStyle.None;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {</span><br /><span style="color: rgb(255, 255, 204);">this.columnHeader1,</span><br /><span style="color: rgb(255, 255, 204);">this.columnHeader2,</span><br /><span style="color: rgb(255, 255, 204);">this.columnHeader3});</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.ForeColor = System.Drawing.SystemColors.ControlLightLight;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.FullRowSelect = true;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.Location = new System.Drawing.Point(2, 1);</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.MultiSelect = false;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.Name = "lstView";</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.OwnerDraw = true;</span><br /><span style="color: rgb(255, 255, 204);">this.lstView.View = System.Windows.Forms.View.Details;</span><br /><br /><span style="color: rgb(255, 255, 204);">private void lstView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> System.Drawing.Drawing2D.LinearGradientBrush GradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.Blue, Color.LightBlue, 270);</span><br /><br /><span style="color: rgb(255, 255, 204);"> e.Graphics.FillRectangle(GradientBrush, e.Bounds);</span><br /><br /><span style="color: rgb(255, 255, 204);"> e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.White), 2), e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 2, e.Bounds.Height - 2);</span><br /><span style="color: rgb(255, 255, 204);"> </span><br /><span style="color: rgb(255, 255, 204);">e.Graphics.DrawString(e.Header.Text, new Font("Arial", 12), new SolidBrush(Color.Yellow), e.Bounds);</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><span style="color: rgb(255, 255, 204);">private void lstView_DrawItem(object sender, DrawListViewItemEventArgs e)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> if (e.Item.Selected)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> e.Graphics.FillRectangle(new SolidBrush(Color.DarkBlue), e.Bounds);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> e.Graphics.DrawString(e.Item.Text, new Font("Arial", 10), new SolidBrush(Color.White), e.Bounds);</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><br /><span style="color: rgb(255, 255, 204);">private void lstView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> e.Graphics.DrawString(e.Item.Text, new Font("Arial", 10), new SolidBrush(Color.White), e.Bounds);</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><br />That's it...<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com1tag:blogger.com,1999:blog-7176498828566901874.post-39887436523248655832009-06-01T23:49:00.001-07:002009-06-03T00:16:45.885-07:00How to change the header backcolor in datagridview C#Here I am trying to get the new design for my DataGridView header back color. So that, I have been tried a lot in Google and got the solution which is explained below.<br /><br />Set the following properties for your DataGridView control by using the properties window.<br /><br /><span style="color: rgb(255, 255, 204);">EnableHeadersVisualStyles = False</span><br /><br /><span style="color: rgb(255, 255, 204);">RowHeadersBorderStyle = Raised</span><br /><br />Then copy the following code in your <span style="font-weight: bold;">Form_Load</span> event.<br /><br /><span style="color: rgb(255, 255, 204);">DataGridViewCellStyle style = this.dataGridView1.ColumnHeadersDefaultCellStyle;</span><br /><span style="color: rgb(255, 255, 204);">style.BackColor = Color.WhiteSmoke;</span><br /><span style="color: rgb(255, 255, 204);">style.ForeColor = Color.Gray;</span><br /><span style="color: rgb(255, 255, 204);">style.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));</span><br /><br />Now run your application, the header style would be changed and showing a new style that we wants.<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com3tag:blogger.com,1999:blog-7176498828566901874.post-20917501629051744812009-05-06T03:46:00.000-07:002009-05-06T03:48:36.813-07:00What is OfType operator in LINQ?<span style="font-weight: bold; color: rgb(255, 255, 255);">OfType operator in LINQ</span><br /><br />OfType operator is used to return objects of a certain type. For example if we have an array of objects which contains strings, decimal, float and numbers or any other. We can use OfType operator to extract only strings or any particular type of values.<br /><br />Here is an example to fetch the string values from an array of objects. See below,<br /><br /><span style="color: rgb(255, 255, 204);">private void Form1_Load(object sender, EventArgs e)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> object[] values = {"test1",45,'c',"test2",34.67,12/12/2009,"test3",4.0,4.4f};</span><br /><span style="color: rgb(255, 255, 204);"> var strings = values.OfType<string>();</span><br /><span style="color: rgb(255, 255, 204);"> int top = 10;</span><br /><span style="color: rgb(255, 255, 204);"> foreach (var s in strings)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> Label lbl = new Label();</span><br /><span style="color: rgb(255, 255, 204);"> lbl.Top = top;</span><br /><span style="color: rgb(255, 255, 204);"> top = top + 30;</span><br /><span style="color: rgb(255, 255, 204);"> lbl.Text = s;</span><br /><span style="color: rgb(255, 255, 204);"> this.Controls.Add(lbl);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><br />You just copy the above code in to Form_Load and run the solution. There will be shown the string values.<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-54237581422937038052009-05-06T02:10:00.000-07:002009-05-06T02:13:36.479-07:00How to disable the Win Form’s Close Button ?<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Csvinoth%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:24.0pt; font-family:"Times New Roman";} span.articletoptitle {mso-style-name:articletoptitle;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <h1><span class="articletoptitle" style="font-size:85%;"><span style=";font-family:Verdana;" >Disable the Win Form’s Close Button using C#</span></span></h1>Here is the simple way to disable the Form’s close button. Just copy the following code in your code behind. Then run the form, surely the close button would be disabled.
<br />
<br /><span style="color: rgb(255, 255, 204);">private const int CP_NOCLOSE_BUTTON = 0x200;</span>
<br /><span style="color: rgb(255, 255, 204);">protected override CreateParams CreateParams</span>
<br /><span style="color: rgb(255, 255, 204);">{</span>
<br /><span style="color: rgb(255, 255, 204);"> get</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> CreateParams myCp = base.CreateParams;</span>
<br /><span style="color: rgb(255, 255, 204);"> myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;</span>
<br /><span style="color: rgb(255, 255, 204);"> return myCp;</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br /><span style="color: rgb(255, 255, 204);">}</span>
<br />
<br />That's it...
<br />
<br /><span style="font-weight: bold; color: rgb(102, 0, 0);">S.VinothkumaR.</span>
<br />
<br />Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com1tag:blogger.com,1999:blog-7176498828566901874.post-6613810872961151672009-05-02T03:52:00.000-07:002009-05-02T03:57:44.543-07:00Differences between XBAP, WPF Standalone and Silverlight<span style="font-weight: bold; color: rgb(255, 255, 255);">Differences between XBAP, WPF Standalone and Silverlight</span><br /><br />WPF applications are divided into two categories.<br /><br />• Standalone WPF Application<br />• XAML browser applications (XBAPs)<br /><br /><br />There is always a confusion between WPF, XBAP and Silverlight. Developers get confused which one to go for while designing a project. Here I will explain all the 3 technologies with the differences<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Standalone WPF Application</span><br /><br /> - WPF applications are installed on end user's machine.<br /><br /> - Appear in Start Menu and Add/Remove Programs.<br /><br /> - Applications can be installed via MSI or ClickOnce.<br /><br /> - User can be offline and use the application. There is no need for Internet connection.<br /><br /> - Newer versions of the application may not be automatically installed in user's machine.<br /><br /> - WPF standalone applications can use WCF for communication.<br /><br /> - Applications run in its own window as other windows applications.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">XAML Browser Application(XBAP)</span><br /><br /><br /> - These type of applications are not installed in user's machine.<br /><br /> - They do not appear in the in Start Menu or Add/Remove Programs.<br /><br /> - Applications can be automatically deployed via ClickOnce.<br /><br /> - Applications are hosted in the browser process.<br /><br /> - Can be run only in IE and Firefox.<br /><br /> - Newer versions are always installed automatically into the user's machine.<br /><br /> - User must be online to use the application.<br /><br /> - XBAP is Windows only. We can run the application in Windows operating system only.<br /><br /> - XBAPs cannot use WCF.<br /><br /> - The user machine should have <span style="font-weight: bold; color: rgb(255, 255, 255);">.NET framework 3.0</span> components.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Silverlight</span><br /><br /> - XBAP is IE and Firefox only. But Silverlight can run in <span style="font-weight: bold;">any browser and platform</span>.<br /><br /> - Silverlight is used for creating rich UI <span style="font-weight: bold;">web application</span>.<br /><br /> - User's machine don't need .NET framework.<br /><br /> - Can be embedded in HTML markup and rendered in any browser using the silverlight plug in.<br /><br /> - XABP has 99% features of WPF. But Silverlight is just a subset of WPF.<br /><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-50702240762874858002009-05-02T03:45:00.000-07:002009-05-02T03:51:16.521-07:00XBAP - Windows Presentation Foundation XAML Browser Applications<span style="font-weight: bold; color: rgb(255, 255, 255);">XBAP - Windows Presentation Foundation XAML Browser Applications</span><br /><br />XBAP – XAML Browser Application is a new windows technology used for creating Rich Internet Applications. It is used for creating heavyweight .Net applications.<br /><br />XAML Browser Applications combines features of both Web applications and rich-client applications. While windows applications are normally compiled to an <span style="font-weight: bold; color: rgb(255, 255, 255);">.exe</span> file, browser applications are compiled to an extension <span style="font-weight: bold; color: rgb(255, 255, 255);">.xbap</span> and can be run inside Internet Explorer.<br /><br />Like Web applications, XBAPs can be published to a Web server and launched from Internet Explorer. Like rich-client applications, XBAPs can take advantage of the capabilities of WPF. Developing XBAPs is also similar to rich-client development.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Implementing a XAML Browser Application (XBAP)</span><br /><br />The simplest way to create a new XBAP project is with Microsoft Visual Studio:<br /><br />1. On the File menu, point to New, and then click Project.<br />2. In the New Project dialog box, in the Project types pane, choose either Visual Basic or Visual<br /> C#. In the Templates pane, click WPF Browser Application.<br />3. Assign a project name and click OK to create the new project.<br /><br />The WPF Browser Application project template creates an XBAP application project that includes the following:<br /><br />• An application definition, Application.xaml.<br />• A page, Page1.xaml.<br /><br />You can add to those as required.<br /><br />If you prefer developing with tools that require command-line compilation.<br /><br />When you run an XBAP, it is launched in a browser window instead of a standalone window. When you debug an XBAP from Visual Studio, the application runs with Internet zone permission and will consequently throw security exceptions if those permissions are exceeded.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Deploying a XAML Browser Application </span><br /><br />When you build a XBAP, the Microsoft build engine (MSBuild) produces the following three files as a minimum:<br /><br /><br />• An executable file. This contains the compiled code and has an .exe extension.<br />• An application manifest. This contains metadata associated with the application and has a<br /> .manifest extension.<br />• A deployment manifest. This file contains the information that ClickOnce uses to deploy the<br /> application and has an .xbap extension.<br /><br />You publish XBAPs to a Web server (Microsoft Internet Information Services (IIS) or later). You do not need to install .NET Framework on the Web server, but you do need to register the WPF Multipurpose Internet Mail Extensions (MIME) types and file extensions.<br /><br />To prepare your XBAP for deployment, copy the .exe and the associated manifests to your Web server. Create a hyperlink on a Web page to navigate to the deployment manifest. When the user clicks the link and navigates to the .xbap file, ClickOnce automatically handles the mechanics of downloading and launching the application.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Reference: </span><br /><br />1. <a href="http://msdn.microsoft.com/en-us/library/aa970060.aspx">http://msdn.microsoft.com/en-us/library/aa970060.aspx</a><br />2. <a href="http://aspalliance.com/1824_Introduction_to_XAML_Browser_Applications_XBAP.1">http://aspalliance.com/1824_Introduction_to_XAML_Browser_Applications_XBAP.1</a><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com2tag:blogger.com,1999:blog-7176498828566901874.post-69184050227510615602009-04-28T22:33:00.000-07:002009-04-28T22:39:54.103-07:00How to create Vista GadgetWe can create a Vista Sidebar Gadget by easily. Just follow the below steps then you are the owner of a sidebar gadget.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Step 1:</span><br /><br />Create the following html file with the name of “<span style="font-weight: bold; color: rgb(255, 255, 255);">HelloWorld.html</span>”.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKlNusLXRLWEFMt1gJm4Vt5pHJ2CuZhSS7OER-FhlN-W2Ac_tTLHXCvtYD7dxhxwuHrUsPA1Mw0dF4NIjM5A4qy68cBKj21Kjpk72ReeZ4fFJ_4e_S7NoMBoOWyAMYBZjGiIRclbhgB3U/s1600-h/html.GIF"><img style="cursor: pointer; width: 320px; height: 309px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKlNusLXRLWEFMt1gJm4Vt5pHJ2CuZhSS7OER-FhlN-W2Ac_tTLHXCvtYD7dxhxwuHrUsPA1Mw0dF4NIjM5A4qy68cBKj21Kjpk72ReeZ4fFJ_4e_S7NoMBoOWyAMYBZjGiIRclbhgB3U/s320/html.GIF" alt="" id="BLOGGER_PHOTO_ID_5329982627959119986" border="0" /></a><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Step 2:</span><br /><br />Create the following xml file with the name of “<span style="font-weight: bold; color: rgb(255, 255, 255);">Gadget.xml</span>”.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqgq-LcQVYDFMHHGj2oRwb8JLqF5v3HsG_pHZzcK1A1hzdlkh_4JNdVKIM_9j87D2gjBkyTfAT3Sksq4pdlInLmU9oTN4xjzeQm2oNNt1wVcsJ6TAQypE0HHodJKw26xtTt1nE8okhzpI/s1600-h/xml.GIF"><img style="cursor: pointer; width: 320px; height: 301px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqgq-LcQVYDFMHHGj2oRwb8JLqF5v3HsG_pHZzcK1A1hzdlkh_4JNdVKIM_9j87D2gjBkyTfAT3Sksq4pdlInLmU9oTN4xjzeQm2oNNt1wVcsJ6TAQypE0HHodJKw26xtTt1nE8okhzpI/s320/xml.GIF" alt="" id="BLOGGER_PHOTO_ID_5329982720655882370" border="0" /></a><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Step 3:</span><br /><br />Create a folder called <span style="font-weight: bold; color: rgb(255, 255, 255);">Helloworld.Gadget</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Step 4:</span><br /><br />1.Simply copy”<span style="font-weight: bold; color: rgb(255, 255, 255);">%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets</span>” and paste in Windows explorer address bar.<br />2. When you get to that folder Copy and Paste the “<span style="font-weight: bold; color: rgb(255, 255, 255);">HelloWorld.Gadget</span>” folder there.<br /><br /><span style="font-weight: bold; color: rgb(255, 255, 255);">Step 5:</span><br /><br />Add the gadget to your Sidebar and your done !<br /><br />For more visit <a href="http://archworx.wordpress.com/2006/11/05/how-to-create-a-vista-sidebar-gadget/">here … </a><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0tag:blogger.com,1999:blog-7176498828566901874.post-77678082536816062422009-04-26T23:19:00.000-07:002009-04-26T23:22:47.986-07:00How to get duration of an audio file in c# ?We can get the duration of an audio or video file by using the “<span style="font-weight: bold; color: rgb(255, 255, 255);">Shell32</span>” namespace in Visual Studio Dot Net. For that we need to add the reference of “<span style="font-weight: bold; color: rgb(255, 255, 255);">Interop.Shell32.dll</span>” in to our project. And follow the given method in below. By calling the following method with the parameter of full path of file name which might be an audio file or video file we can get the duration of that file.
<br />
<br /><span style="color: rgb(255, 255, 204);">private string GetDuration(string FileFullPath)</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> string duration = "";</span>
<br /><span style="color: rgb(255, 255, 204);"> string fName = FileFullPath.Substring(FileFullPath.LastIndexOf("\\") + 1);</span>
<br /><span style="color: rgb(255, 255, 204);"> string filePath = FileFullPath.Substring(0, FileFullPath.LastIndexOf("\\"));</span>
<br /><span style="color: rgb(255, 255, 204);"> Shell32.Shell shell = new Shell32.ShellClass();</span>
<br /><span style="color: rgb(255, 255, 204);"> Shell32.Folder folder = shell.NameSpace(filePath);</span>
<br /><span style="color: rgb(255, 255, 204);"> Shell32.FolderItem folderItem = folder.ParseName(fName);</span>
<br /><span style="color: rgb(255, 255, 204);"> if (folderItem != null)</span>
<br /><span style="color: rgb(255, 255, 204);"> {</span>
<br /><span style="color: rgb(255, 255, 204);"> duration = folder.GetDetailsOf(folderItem, 21);</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br /><span style="color: rgb(255, 255, 204);"> folderItem = null;</span>
<br /><span style="color: rgb(255, 255, 204);"> folder = null;</span>
<br /><span style="color: rgb(255, 255, 204);"> shell = null;</span>
<br /><span style="color: rgb(255, 255, 204);"> return duration;</span>
<br /><span style="color: rgb(255, 255, 204);"> }</span>
<br />
<br /><meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5Csvinoth%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:595.45pt 841.7pt; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->Hence we can get the duration of given file.
<br />
<br /><span style="font-weight: bold; color: rgb(102, 0, 0);">…S.VinothkumaR.</span>
<br />
<br />Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com7tag:blogger.com,1999:blog-7176498828566901874.post-39088718152422868032009-04-20T22:20:00.000-07:002009-05-08T04:39:49.889-07:00Find Age from given DateOfBirth using C#Hi all,<br /><br />Just copy the following method in your class and call it with the parameters of date of birth and current date in DateTime format.<br /><br /><span style="color: rgb(255, 255, 204);">public string FindAge(DateTime dob, DateTime currentDate)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> int years = currentDate.Year - dob.Year;</span><br /><span style="color: rgb(255, 255, 204);"> int months = 0;</span><br /><span style="color: rgb(255, 255, 204);"> int days = 0;</span><br /><span style="color: rgb(255, 255, 204);">if(currentDate < dob.AddYears(Years) && Years != 0)<br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> --years;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> dob = dob.AddYears(years);</span><br /><span style="color: rgb(255, 255, 204);"> if (dob.Year == currentDate.Year)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> months = currentDate.Month - dob.Month;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> else</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> months = (12 - dob.Month) + currentDate.Month;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);">if(currentDate < dob.AddMonths(months) && months != 0)<br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> --months;</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);"> dob = dob.AddMonths(months);</span><br /><span style="color: rgb(255, 255, 204);"> days = (currentDate - dob).Days;</span><br /><span style="color: rgb(255, 255, 204);"> return years + " years " + months + " months " + days + " days";</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><span style="color: rgb(255, 255, 255);">Copy the above code in your class...and call the method..enjoy... ;)</span><br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span></span></span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com1tag:blogger.com,1999:blog-7176498828566901874.post-61734402979212894272009-04-16T06:08:00.000-07:002009-04-16T06:13:09.208-07:00Code for moving the form by mouse clicking.Hi Viewers,<br /><br />Here by I am trying to give you a sample code for moving the win form by clicking the mouse.<br /><br />Just use the following code and test it.<br /><br /><span style="color: rgb(255, 255, 204);">using System.Runtime.InteropServices;</span><br /><br /><span style="color: rgb(255, 255, 204);">public const int WM_NCLBUTTONDOWN = 0xA1;</span><br /><br /><span style="color: rgb(255, 255, 204);">public const int HT_CAPTION = 0x2;</span><br /><br /><span style="color: rgb(255, 255, 204);">[DllImportAttribute("user32.dll")]</span><br /><span style="color: rgb(255, 255, 204);">public static extern int SendMessage(IntPtr hWnd,int Msg, int wParam, int lParam);</span><br /><br /><span style="color: rgb(255, 255, 204);">[DllImportAttribute("user32.dll")]</span><br /><span style="color: rgb(255, 255, 204);">public static extern bool ReleaseCapture();</span><br /><br /><span style="color: rgb(255, 255, 204);">private void Form1_MouseDown(object sender, MouseEventArgs e)</span><br /><span style="color: rgb(255, 255, 204);">{</span><br /><span style="color: rgb(255, 255, 204);"> if (e.Button == MouseButtons.Left)</span><br /><span style="color: rgb(255, 255, 204);"> {</span><br /><span style="color: rgb(255, 255, 204);"> ReleaseCapture();</span><br /><span style="color: rgb(255, 255, 204);"> SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);</span><br /><span style="color: rgb(255, 255, 204);"> }</span><br /><span style="color: rgb(255, 255, 204);">}</span><br /><br /><br />Now you can implement the above code in your application and test it. Working fine for me<br /><br /><span style="font-weight: bold; color: rgb(102, 0, 0);">...S.VinothkumaR.</span>Vinothkumar Shttp://www.blogger.com/profile/04076136185993269386noreply@blogger.com0