I'm creating a DataGridView and using a DataTable to populate it.
My C#
DataGridView dgv = new DataGridView();
DataTable dt = new DataTable();
dt.Columns.Add("Col_1");
dt.Columns.Add("Col_2");
for(int i=0; i< myDictionary; i++)
{
dt.Rows.Add(myDictionary.key, myDictionary.Value);
}
dgv.DataSource = dt;
for(int j=0; j < dgv.Columns.Count; j++)
{...} // this is where Count is always 0...
I'm really just looking to access the columns so that I can do something like
dgv.Columns[j].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Q: How can have the dataGridView reflect the columns properly?