I have a list that I have bound to a datagridview. I want the first column to be a fixed size. The data is bound to the dataGridView and I can't seem to find a way to access an individual colums properties. if I try myDatagridview.colums[0] I get an index out of bounds, since it says the columns count is 0.
private DataGridView setUpDataGrid(List<NVRlineVal> _NVRData)
{
//setup dataGridView
DataGridView NVRDataGridView = new System.Windows.Forms.DataGridView();
NVRDataGridView.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
NVRDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
NVRDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
NVRDataGridView.Name = "NVRDataGridView" + nvrIndex;
NVRDataGridView.RowHeadersWidthSizeMode =
System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
NVRDataGridView.TabIndex = 0;
NVRDataGridView.DataSource = _NVRData;
//var clmn = NVRDataGridView.Columns[0];
return NVRDataGridView;
}
Any ideas on how to have a fixed column width for only one of these columns, the rest will autosize?
edited original code, to show a more cleaned up version that still works