c# datagrid does not set GridColumnStyles

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using c#.net 2003 and have an an application with a datagrid. The
binding is with an array of structs. Everything works ok except the header
text is the struct element names and they override any GridColumnStyles
properties I set. Additionally, the GridColumnStyles width I set does not get
updated on the datagrid. Any other user have this problem or some insight
into what may be going on.
Thanks,
Jim
 
I have had a number of problems with custom styles but to help you please
attach code for reviewal
 
Here is the code from a button_click event:
//Populate the struct array
data[0].SetData("Iin", "Input Current");
data[1].SetData("Vo_HLNL_pct", "High line full load output voltage");

//Create new table style and mapping name
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "Table";

//Create STEP column styles, mapping name and header text
//Bug: header text does not show...Width not changed
DataGridTextBoxColumn cs1 = new DataGridTextBoxColumn();
cs1.MappingName="STEP";
cs1.HeaderText="STEPXxxx";
cs1.Alignment=HorizontalAlignment.Center;
cs1.Width=200;
ts.GridColumnStyles.Add(cs1);

//Create STEP column styles, mapping name and header text
//Bug: Width not changed
DataGridTextBoxColumn cs2 = new DataGridTextBoxColumn();
cs2.MappingName="STEP_DESCRIPTION";
cs2.HeaderText="STEPX_DESCRIPTION";
cs2.Alignment=HorizontalAlignment.Center;
cs2.Width=200;
ts.GridColumnStyles.Add(cs2);

// Add the tablestyle to the datagrid adn bind
dataGrid1.TableStyles.Add(ts);
dataGrid1.DataSource=data;
currencyManager = (CurrencyManager)dataGrid1.BindingContext[data];

Thanks for any help you can give
Jim
 
Back
Top