I'm attempting to create a custom control from dataGridView which includes a checkboxcolumn. I have added the code to produce this and added the newly created checkBoxDataGridView onto my form in a new project.
I have 2 problems:
1. The column gets added a 2nd time when I open and close the form that holds the new checkBoxDataGridView in designtime. You will see in my code I have tried multiple checks, now commented out, so it does not add the column during design time a 2nd time or more than once. Also only needs to add it during designtime, which I guess is no problem if I check whether its been added already.
2. The checkbox column does not instantiate the name I gave it in the controls class. eg.: col.Name = "dgvTickCol"
public class CheckBoxDataGridView : DataGridView
{
public CheckBoxDataGridView()
{
AddCheckColumn();
}
private void AddCheckColumn()
{
//if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
//if (!Columns.Contains("dgvTickCol"))
//if (this.Rows[0].Cells["dgvTickCol"].Value != null)
//if (this.Rows[0].Cells["dgvTickCol"].ColumnIndex == -1)
//{
DataGridViewColumn col = new DataGridViewCheckBoxColumn();
col.Name = "dgvTickCol";
col.HeaderText = "";
col.SortMode = DataGridViewColumnSortMode.NotSortable;
Columns.Add(col);
// }
}
}