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

<channel>
	<title>TechTips &#187; C#</title>
	<atom:link href="http://kshitijsharma.net/category/netaspnetvbnetcsql-server-mysql/net/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://kshitijsharma.net</link>
	<description>.NET/ CSLA.NET / ASP.NET / VB.NET / C# / SQL Server / MySql ..</description>
	<lastBuildDate>Tue, 24 Aug 2010 15:37:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Showing Multiline string in a DataGridView Cell</title>
		<link>http://kshitijsharma.net/2010/08/23/showing-multiline-string-in-a-datagridview-cell/</link>
		<comments>http://kshitijsharma.net/2010/08/23/showing-multiline-string-in-a-datagridview-cell/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 13:53:07 +0000</pubDate>
		<dc:creator>Kshitij Sharma</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://kshitijsharma.net/?p=158</guid>
		<description><![CDATA[Hi,

Recently I need to show multi-line string in a datagridview cell. To achieve that we need to write code in CellFormatting event of DataGridview. Following is the code]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Recently I need to show multi-line string in a datagridview cell. To achieve that we need to write code in CellFormatting event of DataGridview. Following is the code</p>
<pre class="brush: csharp;">
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.Value.Equals(&quot;Error&quot;))
            {
                e.CellStyle.BackColor = Color.Red;
                e.CellStyle.ForeColor = Color.White;

            }
            else
            {
                if ((!e.Value.Equals(&quot;OK&quot;)) &amp;&amp; e.ColumnIndex==2)
                {
                    e.CellStyle.BackColor = Color.Green;
                    e.CellStyle.ForeColor = Color.White;
                    e.CellStyle.WrapMode = DataGridViewTriState.True;
                    dataGridView1.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

                }

            }
        }
</pre>
<p>I hope this help!</p>
<p>Kshitij</p>
<div class='wp_likes' id='wp_likes_post-158'><a class='like' href="javascript:wp_likes.like(158);" title='' ><img src="http://kshitijsharma.net/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(158);">Unlike</a></div>
</div>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fkshitijsharma.net%2F2010%2F08%2F23%2Fshowing-multiline-string-in-a-datagridview-cell%2F', 'Showing+Multiline+string+in+a+DataGridView+Cell')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fkshitijsharma.net%2F2010%2F08%2F23%2Fshowing-multiline-string-in-a-datagridview-cell%2F', title: '+Showing+Multiline+string+in+a+DataGridView+Cell+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://kshitijsharma.net/2010/08/23/showing-multiline-string-in-a-datagridview-cell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add text to the beginning of a file using C#</title>
		<link>http://kshitijsharma.net/2009/12/08/add-text-to-the-beginning-of-a-file-using-c/</link>
		<comments>http://kshitijsharma.net/2009/12/08/add-text-to-the-beginning-of-a-file-using-c/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 11:18:53 +0000</pubDate>
		<dc:creator>Kshitij Sharma</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://kshitijsharma.net/?p=136</guid>
		<description><![CDATA[Hi,

Few days back i needed a code snippet to write a text in starting of all files in a directory. Searched net but could not find any working code. Then i decide to write my own code and come up with following code. I hope ]]></description>
			<content:encoded><![CDATA[<p><!-- You will NOT be able to see the ad on your site! This unit is hidden on your page, and will only display to your search engine traffic (from US and CA). To preview, paste the code up on your site, then add #chitikatest=mortgage to the end of your URL in your browser's address bar.  Example:  www.yourwebsite.com#chitikatest=mortgage. This will show you what the ad would look like to a user who is interested in "mortgages." -->
<script type="text/javascript"><!--
ch_client = "kshitijsharma";
ch_type = "mpu";
ch_width = 500;
ch_height = 250;
ch_noborders=0;
ch_non_contextual = 4;
ch_vertical ="premium";
ch_sid = "Chitika Premium";
var ch_queries = new Array( );
var ch_selected=Math.floor((Math.random()*ch_queries.length));
if ( ch_selected < ch_queries.length ) {
ch_query = ch_queries[ch_selected];
}
//--></script>
<script  src="http://scripts.chitika.net/eminimalls/amm.js" type="text/javascript">
</script></p>
<p>Hi,</p>
<p>Few days back i needed a code snippet to write a text in starting of all files in a directory. Searched net but could not find any working code. Then i decide to write my own code and come up with following code.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-5111267738769255";
/* 468x15_LinkAd_Horizontal, created 6/17/09 */
google_ad_slot = "4303000503";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
I hope this will help guys who are looking to do same.</p>
<pre class="brush: csharp;">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace AddTextToFiles
{
    class Program
    {
        private static DirectoryInfo ds;
        static void Main(string[] args)
        {
            Console.WriteLine(&quot;*********************Written By Kshitij Sharma ***********************&quot;);
            Console.WriteLine(&quot;Please Enter the path and Press enter &quot;);
            string sPath = Console.ReadLine();
            Console.WriteLine(&quot;Please Enter &lt;B style=&quot;BACKGROUND-COLOR: #a0ffff; COLOR: black&quot;&gt;Text&lt;/B&gt; &quot;);
            string sText = Console.ReadLine();
            addText(sPath,sText);
            Console.WriteLine(&quot;*****************Reach Me @ k.sharma78@gmail.com****************&quot;);
            Console.Read();
        }

        private static void addText(string pth,string txt)
        {
            try
            {

                if (!string.IsNullOrEmpty(pth))
                {
                    ds = new DirectoryInfo(pth);
                }
                else
                {
                    ds = new DirectoryInfo(&quot;c:\\testfiles&quot;);
                }
                if (string.IsNullOrEmpty(txt))
                {
                    txt = &quot;&lt;!--#Include File=\&quot;CheckSQL.inc\&quot;--&gt;&quot;;
                }
                foreach (FileInfo f in ds.GetFiles(&quot;*.asp&quot;))
                {
                    Console.WriteLine(&quot;Writing to file--&gt;&quot; + f.Name);
                    string strPath = ds.Root + ds.Name + &quot;\\&quot; + f.Name;
                    StreamReader sr = new StreamReader(strPath);
                    string fileContent = sr.ReadToEnd();
                    sr.Close();
                    StreamWriter sw = new StreamWriter(strPath, false);
                    StringReader gr = new StringReader(fileContent);
                    sw.WriteLine(txt);
                    sw.WriteLine(gr.ReadToEnd());
                    sw.Close();
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.Read();
            }
        }
    }
}
</pre>
</p>
<div class='wp_likes' id='wp_likes_post-136'><a class='like' href="javascript:wp_likes.like(136);" title='' ><img src="http://kshitijsharma.net/wp-content/plugins/wp-likes/images/like.png" alt='' border='0'/>Like</a><span class='text'></span>
<div class='unlike'><a href="javascript:wp_likes.unlike(136);">Unlike</a></div>
</div>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fkshitijsharma.net%2F2009%2F12%2F08%2Fadd-text-to-the-beginning-of-a-file-using-c%2F', 'Add+text+to+the+beginning+of+a+file+using+C%23')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fkshitijsharma.net%2F2009%2F12%2F08%2Fadd-text-to-the-beginning-of-a-file-using-c%2F', title: '+Add+text+to+the+beginning+of+a+file+using+C%23+' })"/></div>]]></content:encoded>
			<wfw:commentRss>http://kshitijsharma.net/2009/12/08/add-text-to-the-beginning-of-a-file-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
