Hi,
I am working on an existing form which populates a datagridview as follows:
It is using a bindingsource because I see at the bottom of the form in designer the BindingSource control.
private void PopulateGrid()
{
System.Data.DataTable dt = TFNGet();
fBS.DataSource = dt;
dGV.AutoGenerateColumns = false;
dGV.DataSource = fBS;
int i = 0;
dGV.Columns[i++].DataPropertyName = "BCode";
dGV.Columns[i++].DataPropertyName = "FDCode";
dGV.Columns[i++].DataPropertyName = "Currency";
dGV.Columns[i++].DataPropertyName = "CCcy";
dGV.Columns[i++].DataPropertyName = "VD";
dGV.Columns[i++].DataPropertyName = "BS";
dGV.Columns[i++].DataPropertyName = "A";
dGV.Columns[i++].DataPropertyName = "PCN";
dGV.Refresh();
}
Now I would like to add a checkbox column as the first column to this dGV called "Failed"
So I am doing the following to do this but the error is:
"Index was out of range. Must be non-negative and less than the size of the collection.
private void PopulateGrid()
{
System.Data.DataTable dt = TFNGet();
dt.Columns.Add("Failed", typeof(Boolean));
fBS.DataSource = dt;
dGV.AutoGenerateColumns = false;
dGV.DataSource = fBS;
int i = 0;
dGV.Columns[i++].DataPropertyName = "BCode";
dGV.Columns[i++].DataPropertyName = "FDCode";
dGV.Columns[i++].DataPropertyName = "Currency";
dGV.Columns[i++].DataPropertyName = "CCcy";
dGV.Columns[i++].DataPropertyName = "VD";
dGV.Columns[i++].DataPropertyName = "BS";
dGV.Columns[i++].DataPropertyName = "A";
dGV.Columns[i++].DataPropertyName = "PCN";
dGV.Columns[i++].DataPropertyName = "Failed";
dGV.Refresh();
}
Any thoughts please?
Thanks