<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-3265342261895825157</atom:id><lastBuildDate>Sat, 13 Dec 2025 11:17:02 +0000</lastBuildDate><category>CSharp</category><category>Jquery</category><category>Logo Design</category><category>Website Template</category><category>Interview Questions and Answers</category><category>SQL</category><title>csharp</title><description>C# Sources Code  And Website Design Tricks.</description><link>http://sourcecodemaster.blogspot.com/</link><managingEditor>noreply@blogger.com (csharp)</managingEditor><generator>Blogger</generator><openSearch:totalResults>47</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-7752604474824379624</guid><pubDate>Wed, 02 Dec 2015 14:23:00 +0000</pubDate><atom:updated>2015-12-02T06:23:35.531-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Display text in DataGridView when there are no rows</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;Display text in DataGridView when there are no rows&lt;/h1&gt;

&lt;pre class=&quot;brush:csharp;&quot;&gt;   
if (dt.Rows.Count &gt; 0)
                {
                    grid1.DataSource = dt;
                    grid1.DataBind();
                }
                else
                {
                    dt.Rows.Add(dt.NewRow());
                    grid1.DataSource = dt;
                    grid1.DataBind();
                    int totalcolums = grid1.Rows[0].Cells.Count;
                    grid1.Rows[0].Cells.Clear();
                    grid1.Rows[0].Cells.Add(new TableCell());
                    grid1.Rows[0].Cells[0].ColumnSpan = totalcolums;
                    grid1.Rows[0].Cells[0].Text = &quot;No Data Found&quot;;
                }
&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2015/12/display-text-in-datagridview-when-there.html</link><author>noreply@blogger.com (csharp)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-8305440762285465821</guid><pubDate>Tue, 01 Dec 2015 17:54:00 +0000</pubDate><atom:updated>2015-12-01T09:54:46.467-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Reading Excel files from C#  OR How to read data from excel file using c#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;Reading Excel files from C# OR How to read data from excel file using c#&lt;/h1&gt;
&lt;p&gt; The following C# source code using Microsoft Excel 12.0 Object Library for reading an Excel file. &lt;/p&gt;

&lt;pre class=&quot;brush:csharp;&quot;&gt; namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp ;
            Excel.Workbook xlWorkBook ;
            Excel.Worksheet xlWorkSheet ;
            Excel.Range range ;

            string str;
            int rCnt = 0;
            int cCnt = 0;

            xlApp = new Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(&quot;sourcecodemaster.xls&quot;, 0, true, 5, &quot;&quot;, &quot;&quot;, true, 

Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, &quot;\t&quot;, false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            range = xlWorkSheet.UsedRange;

            for (rCnt = 1; rCnt &lt;= range.Rows.Count; rCnt++)
            {
                for (cCnt = 1; cCnt &lt;= range.Columns.Count; cCnt++)
                {
                    str = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2 ;
                    MessageBox.Show(str);
                }
            }

            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }

        private void releaseObject(object obj)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                obj = null;
            }
            catch (Exception ex)
            {
                obj = null;
                MessageBox.Show(&quot;Unable to release the Object &quot; + ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        } 

    }
}
  &lt;/pre&gt;

&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2015/12/reading-excel-files-from-c-or-how-to.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-6271262092470713949</guid><pubDate>Tue, 01 Dec 2015 17:51:00 +0000</pubDate><atom:updated>2015-12-01T09:51:40.204-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Converting a string to byte-array without using an encoding (byte-by-byte)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;

&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;Converting a string to byte-array without using an encoding (byte-by-byte)&lt;/h1&gt;

&lt;br /&gt;
&lt;pre class=&quot;brush:csharp;&quot;&gt; static byte[] GetBytes(string str)
{
    byte[] bytes = new byte[str.Length * sizeof(char)];
    System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
    return bytes;
}  &lt;/pre&gt;


&lt;pre class=&quot;brush:csharp;&quot;&gt; static string GetString(byte[] bytes)
{
    char[] chars = new char[bytes.Length / sizeof(char)];
    System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
    return new string(chars);
}&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2015/12/converting-string-to-byte-array-without.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-5661394599821571881</guid><pubDate>Tue, 01 Dec 2015 17:49:00 +0000</pubDate><atom:updated>2015-12-01T09:49:52.825-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>How do you convert Byte Array to Hexadecimal String, and vice versa</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;

&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;How do you convert Byte Array to Hexadecimal String, and vice versa&lt;/h1&gt;

&lt;br /&gt;
&lt;pre class=&quot;brush:csharp;&quot;&gt; public static string ByteArrayToString(byte[] ba)
{
  StringBuilder hex = new StringBuilder(ba.Length * 2);
  foreach (byte b in ba)
    hex.AppendFormat(&quot;{0:x2}&quot;, b);
  return hex.ToString();
}  &lt;/pre&gt;

&lt;br /&gt;
OR
&lt;pre class=&quot;brush:csharp;&quot;&gt;public static string ByteArrayToString(byte[] ba)
{
  string hex = BitConverter.ToString(ba);
  return hex.Replace(&quot;-&quot;,&quot;&quot;);
}  &lt;/pre&gt;


&lt;br /&gt;
OR
&lt;pre class=&quot;brush:csharp;&quot;&gt;  public static byte[] StringToByteArray(String hex)
{
  int NumberChars = hex.Length;
  byte[] bytes = new byte[NumberChars / 2];
  for (int i = 0; i &lt; NumberChars; i += 2)
    bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
  return bytes;
}&lt;/pre&gt;


&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2015/12/how-do-you-convert-byte-array-to.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-8635423717646750336</guid><pubDate>Tue, 01 Dec 2015 17:42:00 +0000</pubDate><atom:updated>2015-12-01T09:50:14.733-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Create Excel (.XLS and .XLSX) file from C#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;

&lt;br /&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;Create Excel (.XLS and .XLSX) file from C#&lt;/h1&gt;

&lt;p&gt; You can use a library called ExcelLibrary. 
&lt;/br&gt;
It&#39;s very simple, small and easy to use. you can use DataSets and DataTables to easily work with Excel data.Here is an example taking data from a database and creating a workbook from it. Note that the ExcelLibrary code is the single line at the bottom:&lt;/p&gt;

&lt;pre class=&quot;brush:csharp;&quot;&gt;   
//Create the dataset and table
DataSet ds = new DataSet(&quot;NewDataSet&quot;);
DataTable dt = new DataTable(&quot;NewDataTable&quot;);

//Set the locale for each
ds.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
dt.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;

//Open a DB connection (example OleDB)
OleDbConnection con = new OleDbConnection(dbConnectionString);
con.Open();

//Create a query and fill the data table with the data from the DB
string sql = &quot;SELECT Whatever FROM MyDBTable;&quot;;
OleDbCommand cmd = new OleDbCommand(sql, con);
OleDbDataAdapter adptr = new OleDbDataAdapter();

adptr.SelectCommand = cmd;
adptr.Fill(dt);
con.Close();

//Add the table to the data set
ds.Tables.Add(dt);

//Here&#39;s the easy part. Create the Excel worksheet from the data set
ExcelLibrary.DataSetHelper.CreateWorkbook(&quot;sourcecodemaster.xls&quot;, ds);

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;

Microsoft Excel 12.0 
&lt;br /&gt;
&lt;pre class=&quot;brush:csharp;&quot;&gt;
using System;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel; 

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

        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

            if (xlApp == null)
            {
                MessageBox.Show(&quot;Excel is not properly installed!!&quot;);
                return;
            }


            Excel.Workbook xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object misValue = System.Reflection.Missing.Value;

            xlWorkBook = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            xlWorkSheet.Cells[1, 1] = &quot;Sheet 1 content&quot;;

            xlWorkBook.SaveAs(&quot;C:\\sourcecodemaster.xls&quot;, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);

            MessageBox.Show(&quot;Excel file created , you can find the file d:\\sourcecodemaster.xls&quot;);
        }

        private void releaseObject(object obj)
        {
            try
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                obj = null;
            }
            catch (Exception ex)
            {
                obj = null;
                MessageBox.Show(&quot;Exception Occured while releasing object &quot; + ex.ToString());
            }
            finally
            {
                GC.Collect();
            }
        }

    }
}
&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2015/12/create-excel-xls-and-xlsx-file-from-c.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-4280133193650619951</guid><pubDate>Mon, 30 Nov 2015 08:55:00 +0000</pubDate><atom:updated>2015-12-01T09:39:41.285-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Connection String</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;
connection string in c#
&lt;/h1&gt;

&lt;p&gt; You can connect your C# application to data in a SQL Server database using the .NET Framework Data Provider for SQL Server. The first step in a C# application is to create an instance of the Server object and to establish its connection to an instance of Microsoft SQL Server.
&lt;br /&gt;
The SqlConnection Object is Handling the part of physical communication between the C# application and the SQL Server Database . An instance of the SqlConnection class in C# is supported the Data Provider for SQL Server Database. The SqlConnection instance takes Connection String as argument and pass the value to the Constructor statement.&lt;/br&gt;
&lt;br /&gt;

&lt;pre class=&quot;brush:php;&quot;&gt;connetionString=&quot;Data Source=ServerName; Initial Catalog=DatabaseName;User ID=UserName;Password=Password&quot;&lt;/pre&gt;

&lt;p&gt; If you have a named instance of SQL Server, you&#39;ll need to add that as well. &lt;/p&gt;
&lt;pre class=&quot;brush:csharp;&quot;&gt; &quot;Server=localhost\sqlexpress&quot;&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;Connect via an IP address&lt;/p&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;connetionString=&quot;Data Source=IP_ADDRESS,PORT; Network Library=DBMSSOCN;Initial Catalog=DatabaseName; User ID=UserName;Password=Password&quot;&lt;/pre&gt;

&lt;p&gt;Trusted Connection from a CE device ( 1433 is the default port SQL )&lt;/p&gt;


&lt;pre class=&quot;brush:php;&quot;&gt; connetionString=&quot;Data Source=ServerName; Initial Catalog=DatabaseName;Integrated Security=SSPI; User ID=myDomain\UserName;Password=Password;&lt;/pre&gt;

&lt;p&gt;Connecting to SQL Server using windows authentication&lt;/p&gt;

&lt;pre class=&quot;brush:php;&quot;&gt; &quot;Server= localhost; Database= employeedetails; Integrated Security=SSPI;&quot;&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2015/11/connection-string.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-6650912195475348955</guid><pubDate>Sat, 28 Nov 2015 11:47:00 +0000</pubDate><atom:updated>2015-11-28T04:04:30.927-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>c# calculator program source code</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;
c# calculator program source code
&lt;/h1&gt;
Today I am going to show you how to build a Calculator. It is recommended that you get the visual studio environment. if you don&#39;t understand the code don&#39;t be afraid to ask questions by leaving a comment below.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnCc83Q5-jG7AqENtFmVfoSeVjHbn3285cHUBaxXGxtTFdSh8uTJ0gm6TXbmbicTndgLtCp4P9QpFXG7pkBCzvHYZkpwCgh8LmXTM5zgwhQuKIPocD3LzBNa-WJw7yZ3XLl5Qq-fZc-qA/s1600/2015-11-28_171915.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnCc83Q5-jG7AqENtFmVfoSeVjHbn3285cHUBaxXGxtTFdSh8uTJ0gm6TXbmbicTndgLtCp4P9QpFXG7pkBCzvHYZkpwCgh8LmXTM5zgwhQuKIPocD3LzBNa-WJw7yZ3XLl5Qq-fZc-qA/s1600/2015-11-28_171915.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;using System;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        float num1, ans;
        int count;
 
        private void btnC_Click_1(object sender, EventArgs e)
        {
            textBox1.Clear();
            count = 0; 
        }
 
        private void btnCE_Click(object sender, EventArgs e)
        {
            
            if (num1==0 &amp;amp;&amp;amp; textBox1.TextLength&amp;gt;0)
            { 
                num1 = 0; textBox1.Clear();  
            }
            else if (num1 &amp;gt; 0 &amp;amp;&amp;amp; textBox1.TextLength &amp;gt; 0)
            { 
                textBox1.Clear();
            }
        
        }
 
        private void btnback_Click(object sender, EventArgs e)
        {
           
            int lenght = textBox1.TextLength-1;
            string text = textBox1.Text;  
            textBox1.Clear();
            for (int i = 0; i &amp;lt; lenght; i++)
                textBox1.Text = textBox1.Text + text[i]; 
        
        }
 
        private void btnminus_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != &quot;&quot;)
            {
                num1 = float.Parse(textBox1.Text);
                textBox1.Clear();
                textBox1.Focus();
                count = 1;
            }
        }
 
        private void btnone_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 1;
        }
 
        private void bttntwo_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 2;
        }
 
        private void btnthree_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 3;
        }
 
        private void btnplus_Click(object sender, EventArgs e)
        {
            num1 = float.Parse(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            count = 2;
        }
 
        private void btnfour_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 4;
        }
 
        private void btnfive_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 5;
        }
 
        private void btnsix_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 6;
        }
 
        private void btnmultiply_Click(object sender, EventArgs e)
        {
            num1 = float.Parse(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            count = 3;
        }
 
        private void btnseven_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 7;
        }
 
        private void btneight_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 8;
        }
 
        private void btnnine_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 9;
        }
 
        private void btndivide_Click(object sender, EventArgs e)
        {
            num1 = float.Parse(textBox1.Text);
            textBox1.Clear();
            textBox1.Focus();
            count = 4; 
        }
 
        private void btnzero_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 0;
        }
 
        private void btnperiod_Click(object sender, EventArgs e)
        {
            int c = textBox1.TextLength;
            int flag = 0;
            string text = textBox1.Text;
            for (int i = 0; i &amp;lt; c; i++)
            { 
                if (text[i].ToString() == &quot;.&quot;) 
                { 
                    flag = 1; break; 
                } 
                else 
                { 
                    flag = 0; 
                } 
            }
            if (flag == 0)
            { 
                textBox1.Text = textBox1.Text + &quot;.&quot;; 
            }
        }
 
        private void btnequal_Click(object sender, EventArgs e)
        {
            compute(count);
        }
 
        public void compute(int count)
        {
            switch (count)
            {
                case 1:
                    ans = num1 - float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                case 2:
                    ans = num1 + float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                case 3:
                    ans = num1 * float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                case 4:
                    ans = num1 / float.Parse(textBox1.Text);
                    textBox1.Text = ans.ToString();
                    break;
                default:
                    break;
            }
        }
       
     }
}
&lt;/pre&gt;
&lt;/div&gt;
</description><link>http://sourcecodemaster.blogspot.com/2015/11/c-calculator-program-source-code.html</link><author>noreply@blogger.com (csharp)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnCc83Q5-jG7AqENtFmVfoSeVjHbn3285cHUBaxXGxtTFdSh8uTJ0gm6TXbmbicTndgLtCp4P9QpFXG7pkBCzvHYZkpwCgh8LmXTM5zgwhQuKIPocD3LzBNa-WJw7yZ3XLl5Qq-fZc-qA/s72-c/2015-11-28_171915.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-3851921560454212468</guid><pubDate>Mon, 11 Aug 2014 06:25:00 +0000</pubDate><atom:updated>2014-12-21T10:29:53.389-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>How to create a Messagebox with “Yes”, “No” choices and a DialogResult in C#?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;
DialogResult dialogResult = MessageBox.Show(&quot;Type Your Message&quot;, &quot;Message Box Title&quot;, MessageBoxButtons.YesNo);
if(dialogResult == DialogResult.Yes)
{
    //Yes Result
}
else if (dialogResult == DialogResult.No)
{
    //No Result
}
&lt;/pre&gt;
&lt;br /&gt;

&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/08/how-to-create-messagebox-with-yes-no.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-970830940444527873</guid><pubDate>Thu, 03 Jul 2014 14:47:00 +0000</pubDate><atom:updated>2014-07-03T07:47:41.014-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>DataGridView Read Only Columns and Rows</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;
DataGridView Read Only Columns and Rows&lt;/h1&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: verdana; text-align: justify;&quot;&gt;The DataGridView control for displaying and editing tabular data. The ReadOnly property indicates whether the data displayed by the cell can be edited or not. You can set ReadOnly Property in three levels. You can make entire dataGridView or entire column or entire row as ReadOnly .&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: verdana; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; font-family: verdana;&quot;&gt;
dataGridView.ReadOnly = true;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; font-family: verdana;&quot;&gt;
dataGridView.Rows[0].ReadOnly = true;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;background-color: white; font-family: verdana;&quot;&gt;
dataGridView.Columns[0].ReadOnly = true;&lt;/div&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;
 private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.ColumnCount = 3;
            dataGridView1.Columns[0].Name = &quot;Product ID&quot;;
            dataGridView1.Columns[1].Name = &quot;Product Name&quot;;
            dataGridView1.Columns[2].Name = &quot;Product Price&quot;;

            string[] row = new string[] { &quot;1&quot;, &quot;Product 1&quot;, &quot;1000&quot; };
            dataGridView1.Rows.Add(row);
            row = new string[] { &quot;2&quot;, &quot;Product 2&quot;, &quot;2000&quot; };
            dataGridView1.Rows.Add(row);
            row = new string[] { &quot;3&quot;, &quot;Product 3&quot;, &quot;3000&quot; };
            dataGridView1.Rows.Add(row);
            row = new string[] { &quot;4&quot;, &quot;Product 4&quot;, &quot;4000&quot; };
            dataGridView1.Rows.Add(row);

            dataGridView1.Rows[1].ReadOnly = true;
        }
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/07/datagridview-read-only-columns-and-rows.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-3224489032056499434</guid><pubDate>Thu, 03 Jul 2014 14:43:00 +0000</pubDate><atom:updated>2014-07-03T07:47:41.010-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>C# DataGridView Binding - SQL Server dataset</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;
C# DataGridView Binding - SQL Server dataset&lt;/h1&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: verdana; text-align: justify;&quot;&gt;The following C# program shows bind a SQL Server dataset to a DataGridView.&lt;/span&gt;


&lt;pre class=&quot;brush:php;&quot;&gt;
 private void button1_Click(object sender, EventArgs e)
        {
            string connectionString = &quot;Data Source=.;Initial Catalog=pubs;Integrated Security=True&quot;;
            string sql = &quot;SELECT * FROM Authors&quot;;
            SqlConnection connection = new SqlConnection(connectionString);
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);
            DataSet ds = new DataSet();
            connection.Open();
            dataadapter.Fill(ds, &quot;Authors_table&quot;);
            connection.Close();
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = &quot;Authors_table&quot;;
        }
&lt;/pre&gt;

&lt;/div&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/07/c-datagridview-binding-sql-server.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-2222349148357947832</guid><pubDate>Thu, 03 Jul 2014 14:38:00 +0000</pubDate><atom:updated>2015-12-02T20:19:07.532-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title></title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;
C# Crystal Reports Export to Pdf&lt;/h1&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: verdana; text-align: justify;&quot;&gt;You have to include two line&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: verdana; text-align: justify;&quot;&gt;in your C# Source Code.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;color: maroon;&quot;&gt;using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;&lt;/pre&gt;
&lt;pre style=&quot;color: maroon;&quot;&gt;
&lt;/pre&gt;
&lt;pre class=&quot;brush:php;&quot;&gt; try
            {
                ExportOptions CrExportOptions ;
                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = &quot;D:\\csharp.pdf&quot;;
                CrExportOptions = cryRpt.ExportOptions;
                {
                    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                    CrExportOptions.FormatOptions = CrFormatTypeOptions;
                }
                cryRpt.Export();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }&lt;/pre&gt;
&lt;/pre&gt;
The Crystal Reports file path in your C# project files location, there you can see CrystalReport1.rpt . So give the full path name of Crystal Reports file like D:\projects\crystalreports\CrystalReport1.rpt 
When you run this program you will get the PDF file in your computer&#39;s D Drive 
&lt;/div&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/07/c-crystal-reports-export-to-pdf-you.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-3198817658613868494</guid><pubDate>Thu, 03 Jul 2014 14:34:00 +0000</pubDate><atom:updated>2015-12-01T08:35:16.078-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>How to use C# string Clone</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;color: blue; font-family: &#39;Times New Roman&#39;, Times, serif;&quot;&gt;
How to use C# string Clone&lt;/h1&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &amp;quot;verdana&amp;quot;; text-align: justify;&quot;&gt;&lt;b&gt;Clone()&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot;; text-align: justify;&quot;&gt;&amp;nbsp;method creates and returns a copy of string object. The CSharp string Clone() method returns a reference to this instance of string.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: &amp;quot;verdana&amp;quot;; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre style=&quot;color: maroon;&quot;&gt;using System;
using System.Windows.Forms;
namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            {
                string str = &quot;Mahesh&quot;;
                string clonedString = null;
                clonedString = (String)str.Clone();
                MessageBox.Show (clonedString);
            }
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://sourcecodemaster.blogspot.com/2014/07/how-to-use-c-string-clone.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-8298924161282647612</guid><pubDate>Sat, 28 Jun 2014 14:28:00 +0000</pubDate><atom:updated>2014-06-28T07:42:35.594-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Website Template</category><title></title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;

&lt;h1&gt;
Top Web Development Blogs&lt;/h1&gt;
&lt;br /&gt;
A creative web development strategy for your website will improve your online presence and increase the amount of quality content your website provides. Your website should be easy to navigate, fully functional, and interesting to those who visit it. There are many blogs about web development and design on the Internet to give you tips and ideas on how to create a dynamic website but there are some blogs that stand out from the rest.
&lt;br /&gt;
&lt;a href=&quot;http://www.uxbooth.com/&quot;&gt; UX BOOTH&lt;/a&gt;&lt;br /&gt;
The UX stands for user experience and this blog is created by and for experienced web designers. There is also a host of guest authors that contribute to the site and allows visitors to subscribe to a specific topic and make their own contributions.
&lt;br /&gt;
&lt;a href=&quot;http://webdesignerwall.com/&quot;&gt;WEB DESIGNER WALL&lt;/a&gt;&lt;br /&gt;
This site is run by and experienced web designer and illustrator who uses this blog to teach others about web design. There are tutorials, ideas, and opportunities for guest bloggers available on Web Designer Wall.
&lt;br /&gt;
&lt;a href=&quot;http://line25.com/&quot;&gt;LINE25&lt;/a&gt;&lt;br /&gt;
Line25 is a combination of tutorials, articles, and examples of well-designed websites that visitors can view and be motivated by. You can receive email updates and new content from Line25 by signing up for them on the site.
&lt;br /&gt;
&lt;a href=&quot;http://www.smashingmagazine.com/&quot;&gt;SMASHING MAGAZINE&lt;/a&gt;&lt;br /&gt;
There is an excellent collection of blogs on Smashing Magazine that covers topics like coding, design, and graphics. This site also features a job board for developers and designers to find employment.
&lt;br /&gt;
&lt;a href=&quot;http://blogfreakz.com/&quot;&gt;BLOGFREAKZ&lt;br /&gt;
Blogfreakz is a well-rounded site for designers and developers with a lot of free content like icons and fonts you can use on your own site. They also accept new writers to come and write about development and related topics.
&lt;br /&gt;
&lt;/a&gt;&lt;a href=&quot;http://logofury.com/&quot;&gt;LOGOFURY&lt;/a&gt;&lt;br /&gt;
LogoFury is a design source for new logo designs and ideas that visitors can use for inspiration. You can also get them to design a logo for you to use on your site.
&lt;br /&gt;
&lt;a href=&quot;http://designrfix.com/&quot;&gt;DESIGNERFIX&lt;/a&gt;&lt;br /&gt;
This site is made up of self-described “design junkies” and has a lot of great content. Designerfix has everything from free giveaways, to their artist of the day and deals on content.
&lt;br /&gt;
&lt;a href=&quot;http://code.tutsplus.com/&quot;&gt;NETTUTS+&lt;/a&gt;&lt;br /&gt;
Nettuts+ is a good-looking site that gives web developers and designers tools for improving their sites by using better technologies and designs. They focus on apps and the technical aspects of sites like HTML and Javascript.
&lt;br /&gt;
&lt;a href=&quot;http://teamtreehouse.com/&quot;&gt;TREEHOUSE&lt;/a&gt;&lt;br /&gt;
Treehouse has a large team of teachers and designers that focus on the educational side of web design and development. They provide quizzes and instructional videos on a variety of topics so visitors can take advantage of detailed lessons that apply to their own sites.
&lt;br /&gt;
&lt;a href=&quot;http://www.webappers.com/&quot;&gt;WEBAPPERS&lt;/a&gt;&lt;br /&gt;
This blog is great for finding open source resources that you can add to your site’s design like stock photos, icons, and Javascript plugins. They pick the best resources that are available on the Internet and offer them in one place so you do not have to search around.
&lt;br /&gt;

&lt;/div&gt;
</description><link>http://sourcecodemaster.blogspot.com/2014/06/top-web-development-blogs-creative-web.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-1818025092709857534</guid><pubDate>Sat, 28 Jun 2014 13:29:00 +0000</pubDate><atom:updated>2014-07-03T07:38:28.137-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>How to send email with attachment from C#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
The System.Net classes uses to communicate with other applications by using the HTTP, TCP, UDP, Socket etc. In the previous program we saw how to SMTP email from C# describes how to send an email with text body . Here we are sending an email with an attachment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;System.Net.Mail.Attachment attachment;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;attachment = new System.Net.Mail.Attachment(&quot;your attachment file&quot;);&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;mail.Attachments.Add(attachment);&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The Gmail SMTP server name is smtp.gmail.com and the port using send mail is 587 . Here using NetworkCredential for password based authentication.&lt;br /&gt;
SmtpServer.Credentials =
  new System.Net.NetworkCredential(&quot;username&quot;, &quot;password&quot;);&lt;br /&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;using System;
using System.Windows.Forms;
using System.Net.Mail;

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

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient(&quot;smtp.gmail.com&quot;);
                mail.From = new MailAddress(&quot;your_email_address@gmail.com&quot;);
                mail.To.Add(&quot;to_address&quot;);
                mail.Subject = &quot;Test Mail - 1&quot;;
                mail.Body = &quot;mail with attachment&quot;;

                System.Net.Mail.Attachment attachment;
                attachment = new System.Net.Mail.Attachment(&quot;your attachment file&quot;);
                mail.Attachments.Add(attachment);

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential(&quot;username&quot;, &quot;password&quot;);
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);
                MessageBox.Show(&quot;mail Send&quot;);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

&lt;/pre&gt;
&lt;/div&gt;
</description><link>http://sourcecodemaster.blogspot.com/2014/06/how-to-send-email-with-attachment-from-c.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-3826482500012439775</guid><pubDate>Sat, 28 Jun 2014 12:24:00 +0000</pubDate><atom:updated>2014-06-28T06:15:22.266-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>C# DataGridView Printing</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;P&gt; Add PrintDocument object to the project and handle the PrintPage event which is called every time a new page is to be printed. Here in the PrintPage event we create a Bitmap Object and draw the DataGridView to the Bitmap Object. In order to run this C# project you have to drag two buttons ,one for load data and one for print command, and drag a PrintDocument control on your form . The following picture shows how to drag PrintDocument Object to your project.
&lt;/p&gt;
&lt;BR/&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUMLxf3hK_GDiCw-q6qJpzVevIpiXzYgoHWqvCD9ijiMA3zhVIoAarzTjqM8h528rONxMcNuFiBo1I2dhGxHybbEHT15cTBtsZ_kSxSwyhmzet8o-MAFcnfSuwFIWPLBwyXosTqEZN74g/s1600/2014-06-28_174832.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUMLxf3hK_GDiCw-q6qJpzVevIpiXzYgoHWqvCD9ijiMA3zhVIoAarzTjqM8h528rONxMcNuFiBo1I2dhGxHybbEHT15cTBtsZ_kSxSwyhmzet8o-MAFcnfSuwFIWPLBwyXosTqEZN74g/s320/2014-06-28_174832.png&quot; /&gt;&lt;/a&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;
&amp;lt;?php
using System;&lt;br/&gt;
using System.Data;&lt;br/&gt;
using System.Windows.Forms;&lt;br/&gt;
using System.Data.SqlClient;&lt;br/&gt;
using System.Drawing;&lt;br/&gt;
&lt;br/&gt;
namespace WindowsFormsApplication1&lt;br/&gt;
{&lt;br/&gt;
    public partial class Form1 : Form&lt;br/&gt;
    {&lt;br/&gt;
        public Form1()&lt;br/&gt;
        {&lt;br/&gt;
            InitializeComponent();&lt;br/&gt;
        }&lt;br/&gt;
&lt;br/&gt;
        private void button1_Click(object sender, EventArgs e)&lt;br/&gt;
        {&lt;br/&gt;
            string connectionString = &quot;Data Source=.;Initial Catalog=pubs;Integrated Security=True&quot;;&lt;br/&gt;
            string sql = &quot;SELECT * FROM NAME&quot;;&lt;br/&gt;
            SqlConnection connection = new SqlConnection(connectionString);&lt;br/&gt;
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);&lt;br/&gt;
            DataSet ds = new DataSet();&lt;br/&gt;
            connection.Open();&lt;br/&gt;
            dataadapter.Fill(ds, &quot;NAME&quot;);&lt;br/&gt;
            connection.Close();&lt;br/&gt;
            dataGridView1.DataSource = ds;&lt;br/&gt;
            dataGridView1.DataMember = &quot;NAME&quot;;&lt;br/&gt;
&lt;br/&gt;
        }&lt;br/&gt;
&lt;br/&gt;
        private void button2_Click(object sender, EventArgs e)&lt;br/&gt;
        {&lt;br/&gt;
            printDocumentS.Print();&lt;br/&gt;
        }&lt;br/&gt;
&lt;br/&gt;
        private void printDocumentS_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)&lt;br/&gt;
        {&lt;br/&gt;
            Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);&lt;br/&gt;
            dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));&lt;br/&gt;
            e.Graphics.DrawImage(bm, 0, 0);&lt;br/&gt;
        }&lt;br/&gt;
 &lt;br/&gt;
    }&lt;br/&gt;
}&lt;br/&gt;
&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/c-datagridview-printing.html</link><author>noreply@blogger.com (csharp)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUMLxf3hK_GDiCw-q6qJpzVevIpiXzYgoHWqvCD9ijiMA3zhVIoAarzTjqM8h528rONxMcNuFiBo1I2dhGxHybbEHT15cTBtsZ_kSxSwyhmzet8o-MAFcnfSuwFIWPLBwyXosTqEZN74g/s72-c/2014-06-28_174832.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-2461302789246360969</guid><pubDate>Sat, 28 Jun 2014 12:14:00 +0000</pubDate><atom:updated>2014-06-28T06:15:22.261-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>C# DataGridView Export to Excel</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;p&gt;The DataGridView control is designed to be a complete solution for displaying tabular data with Windows Forms. The DataGridView control is highly configurable and extensible, and it provides many properties, methods, and events to customize its appearance and behavior. The following C# source code shows how to Export the content of a datagridview to an Excel file.&lt;/p&gt;
&lt;br/&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;
&amp;lt;?php
using System;&lt;br/&gt;
using System.Data;&lt;br/&gt;
using System.Windows.Forms;&lt;br/&gt;
using System.Data.SqlClient;&lt;br/&gt;
using Excel = Microsoft.Office.Interop.Excel;&lt;br/&gt;
&lt;br/&gt;
namespace WindowsFormsApplication1&lt;br/&gt;
{&lt;br/&gt;
    public partial class Form1 : Form&lt;br/&gt;
    {&lt;br/&gt;
        public Form1()&lt;br/&gt;
        {&lt;br/&gt;
            InitializeComponent();&lt;br/&gt;
        }&lt;br/&gt;

        private void button1_Click(object sender, EventArgs e)&lt;br/&gt;
        {&lt;br/&gt;
            string connectionString = &quot;Data Source=.;Initial Catalog=pubs;Integrated Security=True&quot;;&lt;br/&gt;
            string sql = &quot;SELECT * FROM Authors&quot;;&lt;br/&gt;
            SqlConnection connection = new SqlConnection(connectionString);&lt;br/&gt;
            SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection);&lt;br/&gt;
            DataSet ds = new DataSet();&lt;br/&gt;
            connection.Open();&lt;br/&gt;
            dataadapter.Fill(ds, &quot;Authors_table&quot;);&lt;br/&gt;
            connection.Close();&lt;br/&gt;
            dataGridView1.DataSource = ds;&lt;br/&gt;
            dataGridView1.DataMember = &quot;Authors_table&quot;;&lt;br/&gt;
        }&lt;br/&gt;

        private void button2_Click(object sender, EventArgs e)&lt;br/&gt;
        {&lt;br/&gt;
            Excel.Application xlApp;&lt;br/&gt;
            Excel.Workbook xlWorkBook;&lt;br/&gt;
            Excel.Worksheet xlWorkSheet;&lt;br/&gt;
            object misValue = System.Reflection.Missing.Value;&lt;br/&gt;
&lt;br/&gt;
            Int16 i, j;&lt;br/&gt;
&lt;br/&gt;
            xlApp = new Excel.ApplicationClass();&lt;br/&gt;
            xlWorkBook = xlApp.Workbooks.Add(misValue);&lt;br/&gt;
&lt;br/&gt;
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);&lt;br/&gt;
&lt;br/&gt;
            for (i = 0; i &lt;= dataGridView1.RowCount - 2; i++)&lt;br/&gt;
            {&lt;br/&gt;
                for (j = 0; j &lt;= dataGridView1.ColumnCount - 1; j++)&lt;br/&gt;
                {&lt;br/&gt;
                    xlWorkSheet.Cells[i + 1, j + 1] = dataGridView1[j, i].Value.ToString();&lt;br/&gt;
                }&lt;br/&gt;
            }&lt;br/&gt;

            xlWorkBook.SaveAs(@&quot;c:\csharp.net-informations.xls&quot;, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);&lt;br/&gt;
            xlWorkBook.Close(true, misValue, misValue);&lt;br/&gt;
            xlApp.Quit();&lt;br/&gt;

            releaseObject(xlWorkSheet);&lt;br/&gt;
            releaseObject(xlWorkBook);&lt;br/&gt;
            releaseObject(xlApp);&lt;br/&gt;
        }&lt;br/&gt;

        private void releaseObject(object obj)&lt;br/&gt;
        {&lt;br/&gt;
            try&lt;br/&gt;
            {&lt;br/&gt;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);&lt;br/&gt;
                obj = null;&lt;br/&gt;
            }&lt;br/&gt;
            catch (Exception ex)&lt;br/&gt;
            {&lt;br/&gt;
                obj = null;&lt;br/&gt;
                MessageBox.Show(&quot;Exception Occured while releasing object &quot; + ex.ToString());&lt;br/&gt;
            }&lt;br/&gt;
            finally&lt;br/&gt;
            {&lt;br/&gt;
                GC.Collect();&lt;br/&gt;
            }&lt;br/&gt;
        }&lt;br/&gt;
    }&lt;br/&gt;
}&lt;br/&gt;
&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/c-datagridview-export-to-excel.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-2456496493577743470</guid><pubDate>Fri, 27 Jun 2014 04:36:00 +0000</pubDate><atom:updated>2014-06-28T06:15:22.257-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>how to get the list of all printers in computer - C# Winform</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;p&gt;how to get the list of all printers in computer - C# Winform&lt;/P&gt;
&lt;BR/&gt;
&lt;P&gt;&lt;BR/&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;
&amp;lt;?php
foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)&lt;BR/&gt;
        {&lt;BR/&gt;
            MessageBox.Show(printer);&lt;BR/&gt;
        }&lt;BR/&gt;
&lt;/pre&gt;
&lt;/P&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/how-to-get-list-of-all-printers-in.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-5477608991424859429</guid><pubDate>Fri, 27 Jun 2014 02:32:00 +0000</pubDate><atom:updated>2014-06-28T06:15:22.276-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Best way to implement keyboard shortcuts in a Windows Forms application?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;p&gt;I&#39;m looking for a best way to implement common Windows keyboard shortcuts (for example Ctrl+F, Ctrl+N) in my Windows Forms application in C#.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;You probably forget to set the form&#39;s KeyPreview property to True. Overriding the ProcessCmdKey() method is the generic solution:&lt;/p&gt;
&lt;br/&gt;
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) &lt;br/&gt;
{&lt;br/&gt;
  if (keyData == (Keys.Control | Keys.F)) {&lt;br/&gt;
    MessageBox.Show(&quot;What the Ctrl+F?&quot;);&lt;br/&gt;
    return true;&lt;br/&gt;
  }&lt;br/&gt;
  return base.ProcessCmdKey(ref msg, keyData);&lt;br/&gt;
}&lt;br/&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/best-way-to-implement-keyboard.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-5439795390309399523</guid><pubDate>Fri, 27 Jun 2014 02:27:00 +0000</pubDate><atom:updated>2014-06-28T06:15:22.271-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>How do I make a textbox that only accepts numbers?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;p&gt;Handle the appropriate keyboard events to prevent anything but numeric input. I&#39;ve had success with this two event handlers on a standard TextBox:&lt;/p&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;
&amp;lt;?php
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)&lt;br /&gt;
{&lt;br /&gt;
    if (!char.IsControl(e.KeyChar) &lt;br /&gt;
        &amp;&amp; !char.IsDigit(e.KeyChar) &lt;br /&gt;
        &amp;&amp; e.KeyChar != &#39;.&#39;)&lt;br /&gt;
    {&lt;br /&gt;
        e.Handled = true;&lt;br /&gt;
    }&lt;br /&gt;

    // only allow one decimal point&lt;br /&gt;
    if (e.KeyChar == &#39;.&#39; &lt;br /&gt;
        &amp;&amp; (sender as TextBox).Text.IndexOf(&#39;.&#39;) &gt; -1)&lt;br /&gt;
    {&lt;br /&gt;
        e.Handled = true;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/how-do-i-make-textbox-that-only-accepts.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-5694354910322794851</guid><pubDate>Wed, 25 Jun 2014 16:43:00 +0000</pubDate><atom:updated>2014-06-28T06:15:22.281-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>combobox Autocomplete</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;P&gt;Since you&#39;ve declared CustomSource for auto completion, you should provide that source:&lt;/p&gt;
&lt;br/&gt;
&lt;p&gt;
&lt;pre class=&quot;brush:php;&quot;&gt;

private void frmInvoice_Load(object sender, EventArgs e)    &lt;br/&gt;  
{&lt;br/&gt;
    comboBox1.AutoCompleteMode=AutoCompleteMode.Append;&lt;br/&gt;
    comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource; &lt;br/&gt;
    AutoCompleteStringCollection data = new AutoCompleteStringCollection();&lt;br/&gt;
    // Put here the auto completions&#39; e.g. &lt;br/&gt;
    data.Add(&quot;My String 1&quot;);&lt;br/&gt;
    data.Add(&quot;Autocompletion 2&quot;);&lt;br/&gt;
    data.Add(&quot;Some stuff&quot;);&lt;br/&gt;
    comboBox1.AutoCompleteCustomSource = data;&lt;br/&gt;
}&lt;/p&gt;

&lt;br/&gt;
&lt;/pre&gt;
or

use this&lt;br/&gt;

&lt;pre class=&quot;brush:php;&quot;&gt;
private void LoadStuffNames()&lt;br/&gt;
{&lt;br/&gt;

    try&lt;br/&gt;
    {&lt;br/&gt;
            string Query = &quot;select stuff_name from dbo.stuff&quot;;&lt;br/&gt;
            string[] names = GetColumnData_FromDB(Query);&lt;br/&gt;

            comboName.AutoCompleteMode = AutoCompleteMode.Suggest;&lt;br/&gt;
            comboName.AutoCompleteSource = AutoCompleteSource.CustomSource;&lt;br/&gt;
            AutoCompleteStringCollection x = new AutoCompleteStringCollection();&lt;br/&gt;
            if (names != null &amp;&amp; names.Length &gt; 0)&lt;br/&gt;
                foreach (string s in names)&lt;br/&gt;
                    x.Add(s);&lt;br/&gt;

            comboName.AutoCompleteCustomSource = x;&lt;br/&gt;
    }&lt;br/&gt;
    catch (Exception ex)&lt;br/&gt;
    {&lt;br/&gt;
    }&lt;br/&gt;
    finally&lt;br/&gt;
    {&lt;br/&gt;
    }&lt;br/&gt;

}&lt;br/&gt;&lt;/pre&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/combobox-autocomplete.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-5806806488966433244</guid><pubDate>Wed, 25 Jun 2014 16:32:00 +0000</pubDate><atom:updated>2014-06-28T06:30:56.137-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SQL</category><title>Auto increment primary key in SQL Server Management Studio</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;P&gt;Make sure that the Key column&#39;s datatype is int and then setting identity manually, as image show&lt;/p&gt;
&lt;br/&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ9XxROFgP6cnQVHWH-gFO0oAHqHqGo2UXuL2L5lQ8orOXG6D5x_7SWEOQyWCB6bdqx87pEzbeIr2GGwbBqiurwfPQ5nxA5jYJOpOs5NDpI9g0EmDPbyGVoLnQ1b5pXbSWe6lfXTY-Z8w/s1600/auto.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ9XxROFgP6cnQVHWH-gFO0oAHqHqGo2UXuL2L5lQ8orOXG6D5x_7SWEOQyWCB6bdqx87pEzbeIr2GGwbBqiurwfPQ5nxA5jYJOpOs5NDpI9g0EmDPbyGVoLnQ1b5pXbSWe6lfXTY-Z8w/s320/auto.png&quot; /&gt;&lt;/a&gt;
&lt;br/&gt;
&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/06/auto-increment-primary-key-in-sql.html</link><author>noreply@blogger.com (csharp)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ9XxROFgP6cnQVHWH-gFO0oAHqHqGo2UXuL2L5lQ8orOXG6D5x_7SWEOQyWCB6bdqx87pEzbeIr2GGwbBqiurwfPQ5nxA5jYJOpOs5NDpI9g0EmDPbyGVoLnQ1b5pXbSWe6lfXTY-Z8w/s72-c/auto.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-7782840130097109822</guid><pubDate>Wed, 22 Jan 2014 02:08:00 +0000</pubDate><atom:updated>2014-01-21T18:12:07.450-08:00</atom:updated><title>8 Websites Every Microsoft .NET Developer Should Know About</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;p&gt;There are currently millions of developers worldwide that are using Microsoft.NET technologies. If you are one of them or want to become one, then each of the websites I am about to list should be in your list of favorites, your list of bookmarks, or just written down on a piece of paper (yeah right, as if a .NET developer would use a pen and paper).&lt;/p&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codeproject.com/&quot;&gt;codeproject&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/&quot;&gt;MSDN&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspnet.4guysfromrolla.com/&quot;&gt;aspnet.4guysfromrolla&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.dnnsoftware.com/&quot;&gt;dnnsoftware&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/&quot;&gt;stackoverflow&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/01/8-websites-every-microsoft-net.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-302924496059114126</guid><pubDate>Wed, 22 Jan 2014 01:41:00 +0000</pubDate><atom:updated>2014-01-21T17:41:58.386-08:00</atom:updated><title>New Google Sheets: faster, more powerful, and works offline</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;P&gt;Whether you’re crunching big data or tracking your family budget, you don’t want to waste time waiting for files to load or re-doing edits that were lost because your Internet connection dropped. You can now get more done by switching to the new version of Google Sheets. It’s faster, supports larger spreadsheets, has a number of new features, and works offline.&lt;/p&gt;&lt;br/&gt;
 &lt;a href=&quot;http://googleblog.blogspot.in/2013/12/new-google-sheets-faster-more-powerful.html&quot;&gt;Read More&lt;/a&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2014/01/new-google-sheets-faster-more-powerful.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-5469962140067536940</guid><pubDate>Sat, 07 Dec 2013 04:14:00 +0000</pubDate><atom:updated>2014-06-28T06:16:26.216-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>C# - Read a nvarchar (dd/MM/yyyy) into a dateTimePicker</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
dateTimePicker.Value = DateTime.Parse(reader[&quot;Date&quot;].ToString());
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2013/12/c-read-nvarchar-ddmmyyyy-into.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3265342261895825157.post-1312150990098578048</guid><pubDate>Fri, 06 Dec 2013 16:31:00 +0000</pubDate><atom:updated>2014-06-28T06:16:26.202-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">CSharp</category><title>Pass value from one form to another form in c#</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;
&lt;p&gt;Pass value from one form to another form in c#&lt;/p&gt;&lt;br/&gt;
&lt;p&gt; pass id from one form to another from in C#.&lt;/p&gt;&lt;br/&gt;
In Form1&lt;br/&gt;
private void ShowForm2()
{
    string value = TheTextBox.Text;
    Form2 newForm = new Form2();
    newForm.TheValue = value;
    newForm.ShowDialog();
}
In Form2&lt;br&gt;
private string _theValue;
public string TheValue 
{ 
    get
    {
        return _theValue;
    }
    set
    {
        _theValue = value; 
        // do something with _theValue so that it
        // appears in the UI

    }
}

&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://sourcecodemaster.blogspot.com/2013/12/pass-value-from-one-form-to-another.html</link><author>noreply@blogger.com (csharp)</author><thr:total>0</thr:total></item></channel></rss>