Home Forums WinForms controls Xceed Grid for WinForms Dynamically creating a HeaderRow Reply To: Dynamically creating a HeaderRow

User (Old forums)
Member
Post count: 23064

Hi André,

I tried to do what you’ve told me to, but I’m getting the readonly or fixed size error.
Here, take a look at my code

ColumnManagerRow cmrHeader = new ColumnManagerRow(); // Header Row
MyGrid.FixedHeaderRows.Add(cmrHeader);

//Reading the column names from the table and copying to the header row
foreach (System.Data.DataColumn col in dtbActualTable.Columns)
{
   if (MyResource.ResourceManager.GetString(col.ColumnName) != null)
   {
      if (col.ColumnName == “Tax”)
      {
          Xceed.Grid.DataCell cell = new Xceed.Grid.DataCell(“Tax (% a.a.)”);
          cmrHeader.Cells.Add(cell); // ERROR: Cannot add an item to a ReadOnly or FixedSize list.
          cell.Value = “Tax (% a.a.)”;
      }
     else
     {
          //Here i tried a different method.
          cmrHeader.Cells.Add(new Xceed.Grid.DataCell(MyResource.ResourceManager.GetString(col.ColumnName))); // ERROR: Same error above
     }
  }
}

Do you know what am I doing wrong ?
Thanks in advance
Oscar

Imported from legacy forums. Posted by Oscar (had 424 views)