Our app has a form that uses a BindingSource with a DataGridView. I've been tasked with adding a column. I don't know where to begin.
(In my own programming, I avoid black boxes that I don't understand.)
Our app has a form that uses a BindingSource with a DataGridView. I've been tasked with adding a column. I don't know where to begin.
(In my own programming, I avoid black boxes that I don't understand.)
The DataGridView control allows you to use auto generated columns or define your own. I'm using a DataGridView with columns I've defined, so I don't know if you can add a column if it's set to auto generate them (as might be the case for your data bound DataGridView).
The steps would be:
dataGridView1.AutoGenerateColumns = false;
//create column
DataGridViewTextBoxColumn nameColumn = new DataGridViewTextBoxColumn();
nameColumn.Name = "Name";
nameColumn.DataPropertyName = "Name";
nameColumn.HeaderText = "Action";
nameColumn.Width = 140;
nameColumn.FillWeight = 25;
dataGridView1.Columns.Add(nameColumn);
dataGridView1.Columns["Name"].ReadOnly = true;
If you create all columns manually, add them the same way and then add the binding info.