0
votes

DataSource of a BindingSource is a class with some public properties. Columns of the grid were created like this:

DataGridViewTextBoxColumn vendorIDColumn =
           new DataGridViewTextBoxColumn()
           {
               MinimumWidth = 50,
               FillWeight = 20,
               DataPropertyName = "VendorID",
               HeaderText = "Vendor ID",
               AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
           };
        grid.Columns.Add(vendorIDColumn);

DataGridView's property "AutoGenerateColumns" were set to 'false'. Tried grid.Columns[0].DefaultCellStyle.BackColor = Color.Red; but it didn't work.

1

1 Answers

0
votes

Can you set the backcolor of the DataGridViewTextBoxColumn ?

DataGridViewTextBoxColumn vendorIDColumn =
       new DataGridViewTextBoxColumn()
       {
           MinimumWidth = 50,
           FillWeight = 20,
           DataPropertyName = "VendorID",
           HeaderText = "Vendor ID",
           AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
           BackColor = Color.Red;
       };
    grid.Columns.Add(vendorIDColumn);