Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridView dont show nothing

$
0
0

hi, 
I have made ​​several attempts but all went in vain. 

my datagridview does not show anything even though I Have the data in the datatable in the dataset and datagridview datasource to check when nothing is shown on the form.

private void btnxOk_Click(object sender, EventArgs e)
       {
           string Query = "SELECT t_Desc as Desc,p_StartDate AS Start";

           DataTable dt = new DataTable("Try");
           DataSet ds = new DataSet();
           OleDbDataAdapter da = new OleDbDataAdapter(Query, _Myconn.OleDbConnection);
           try
           {
               da.Fill(ds);
               da.Fill(dt);
           }
           catch
           {
               MessageBox.Show("Error!");
           }

         
           
           dataGridView1.AutoGenerateColumns = true;
         
           //dont work
           dataGridView1.DataSource = dt.DefaultView ;

          //Dont work
           dataGridView1.DataSource = ds.Tables[0];
          //in datagridview i have 3 columns but dont showed
           dataGridView1.Refresh();
}

a big thank you to those who help me

Massimo


www.Photoballot.net



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>