I am trying to change formating of specific columns in the grid.
No problem to change the TextColor but i was unable to change the backcolor and TextAlign.
I tried ChangeCell and ColStyles and both have the same effect.
Is there something i am doing wrong?
ADAdministrator Syncfusion Team July 8, 2003 04:43 AM
In a GridDataBoundGrid, you should use the GridBoundColumn.StyleInfo object to set column styles. For each column, you can get this object through either from the grid.GridBoundColumns collection if you have explicitly added GridBoundColumns to your grid, or from grid.Binder.InternalColumns if you have not added them.
Also, TextAlign is used to position text relative to a cell button. If you want to align text in teh cell, then use the HorizontalAlignment property instead of TextAlign.
this.grid.Binder.InternalColumns["Col2"].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
ESEli SmadarJuly 8, 2003 05:15 AM
I tried using the GridBoundColumnsColllection as well and nothing seems to help. Here is the code i am using.
GridBoundColumnsCollection colCols = this.grdLines.GridBoundColumns;
col = new GridBoundColumn();
col.HeaderText = "Name";
col.MappingName = "Name";
col.ReadOnly = true;
col.StyleInfo.BackColor = SystemColors.ControlLight;
ADAdministrator Syncfusion Team July 8, 2003 06:03 AM
Don't set ReadOnly = true until the last change. If you set it, you will not be able to programatically change the style either unless you have explicitly set grid.IgnoreReadOnly = true before you start changing things. Then later you would want to turn IgnoreReadOnly off so the column will not ignore the readonly flag.
ESEli SmadarJuly 8, 2003 06:19 AM
The HorizontalAlign worked - Thank you.
Sorry but the backcolor still not working.
Could it be any setting in the grid?
ADAdministrator Syncfusion Team July 8, 2003 10:51 AM
I think it should work. Attached is a little project where I copied and pasted your code, and it seems to work there. What is different about what you are doing?
ESEli SmadarJuly 9, 2003 06:48 AM
I think i found the bug.
If you set the background Image to something and then delete it - No more backcolor influance.
When with a backgroundImage then i couldn't set the backcolor at all - why?