I have a DataGridView with properties DataSource = datatable()
and readonly = false
. readonly
must be false since there are other columns that can be editable. How do I make all the columns in DataSource read only (not editable)?
The code is as follows:
type = new DataGridViewComboBoxColumn();
table= new DataGridView
{
DataSource = datatable(), // this returns a DataTable object
AllowUserToAddRows = false,
AllowUserToDeleteRows = false,
RowHeadersVisible = false,
MultiSelect = false,
Name = "AgentTable",
AutoSize = true,
ReadOnly = false,
};
table.Columns.Add(CreateStartButton());
type.Items.Add(" some table");
type.ReadOnly = false;
table.Columns.Add(type);
EDIT: the datagridview will contain 4 columns.
- First column, each cell is a button (readonly doesnt matter)
- second column, each cell is a drop down box (readonly is false)
- third and fourth columns are created as DataTable object so (readonly must be true)
so my question is how to make the third and forth column read-only?