Tuesday, 13 August 2019

AATH: AUto Generataion



  1. DataTable dt = new DataTable();
  2. dt.Columns.Add("Column1", typeof(String)); // First col is a string
  3. dt.Columns.Add("Column2", typeof(Boolean)); // Second col is a boolean
  4. DataRow dr = dt.NewRow();
  5. dr["Column1"] = "Data";
  6. dr["Column2"] = true;
  7. dt.Rows.Add(dr);
  8. dataGridView1.DataSource = dt;



AATH:

The AutoGenerateColumns property of DataGrid should set to [AutoGenerateColumns="false"] when creating the dataGrid and customized columns should be define as per the requirement.

1 comment: