title: Bind Datatable data to Gridview in Windows form
body: <p>I search all over the stackoverflow and unable to find a suitable answer for my problem.
  I wanted to bind datatable values to datagridview in windows form.Specially data table in one class and Gridview in Seperate file.</p>
  
  <p>Here is my Code.</p>
  
  <pre><code>namespace MyProj
  {
    public partial class ThisAddIn
  {
    public string GetDetails()
      {
        // Some Codes here
        DataTable dt = new DataTable();
          dt.Columns.Add("id");
          dt.Columns.Add("uid");
          dt.Columns.Add("email");
  
          //Some codes here.I just only give a data table part only.
  
           DataRow row = dt.NewRow();
  
             row["id"] = sid;
             sid++;
  
             row["uid"] = uid;
             row["email"] = e;
             dt.Rows.Add(row);
      }
  }
  }
  </code></pre>
  
  <p>I Just tried to add Gridview,here is that code.
  First i add Add -> NewItem -> WindowsForm &amp; add as form1.cs</p>
  
  <p>Then i add Gridview to this form1.cs class from toolbox.Then double click gridview.</p>
  
  <p>Here is my form1.cs coding</p>
  
  <pre><code>private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
      {
          //ThisAddIn th = new ThisAddIn();
          this.dataGridView1.Visible = true;
          dataGridView1.AutoGenerateColumns = false;
          dataGridView1.DataSource =dt; // here show dt does not contain the current context. 
  </code></pre>
  
  <p>}</p>
  
  <p>Both files are under same namespace.When i tries to create a object from a class (ThisAddIn th = new ThisAddIn();)then it shows,   </p>
  
  <blockquote>
    <blockquote>
      <p>ThisAddIn.ThisAddIn(Microsoft.Office.tools.Outlook Factory factory,IsServiceProvider serviceProvider)</p>
      
      <p>This AddIn does not contain a constructor that takes 0 arguments         </p>
    </blockquote>
  </blockquote>
  
  <p>I'm a fresher to c# and please help me to solve this problem,If you can give me a solution with explanation is great..</p>