AD
Administrator
Syncfusion Team
June 28, 2006 04:46 PM UTC
Hi Palmer,
The reason is that you are misspelled the BaseStylesMap[ "standard"]( BaseStylesMap is a case sensitive). Try this code
//"S" is capital in "Standard" BaseStylesMap
grid.ChangeCells (GridRangeInfo.Cells (0,0,0,grid.ColCount), grid.BaseStylesMap["Standard"].StyleInfo, StyleModifyType.Copy);
Let me know if this helps.
Best Regards,
Haneef
EP
Eldritch Palmer
June 29, 2006 03:09 PM UTC
Hi Haneef,
Unfortunately that doesn''t work either.
While I have found some kludgy workarounds I''m trying to get to grips with how the styles system works.
If you bear with me here for a bit I''ll just set up the situation and then I''ll have some questions for you on why stuff I think should work doesn''t work.
I''ve created the grid by dragging a new instance from the toolbox. I have made no modifications to any of the styles, nor created new ones.
So, initially there are 4 basestyles defined: standard, header, row header & column header.
Row header and column header both specify header as the base style.
The grid is setup with both row & column headers.
I''ve used Style.Identity.GetBaseStyles to check which cells have what styles applied, this results in:
TableStyle == Standard
RowStyles[0] == style: no properties initialised + Standard
ColStyles[0] == style: no properties initialised + Standard
Cell[0,0] == Header + Standard
Cell[0,1] == Column Header + Header + Standard
Cell[1,0] == Row Header + Header + Standard
Cell[1,1] == 3 * style: no properties initialised + Standard
(style: no properties initialised is a style that returns the empty string when calling ToString() on it)
Now, it''s my understanding that when accessing the StyleInfo of a cell, you get an accumulated view of all styles that are applied to that cell taking into account the order of precedence between styles.
Q0. What are those empty styles?
Q1. Going on the output of GetBaseStyles, I assume that the row/column headers are set at the cell level and not at the row/column level.
is this correct?
Q2. Does ChangeCells operate exclusively at the Cell style level? in other words does ChangeCells change the appearance of cells by changing the window through which styles from a lower precedence level are seen without actually affecting those lower precedence levels directly?
Q3. If ChangeCells can only affect the Cell precedence level, is this a correct interpretation of the various StyleModifyType enum:
Override - set the values(*) at the Cell level
ApplyNew - set the values at the cell level, unless there''s a non-default value in a lower-precedence level
Copy - set the values as override and clear all other values at the Cell level
Exclude - clears the values at the Cell level
Remove - clear all properties at the Cell level(**)
Changes - set the changed values as override and clear the changed but now default values at the Cell level.
(*) with ''the values'' I mean, those properties that have been assigned a value in the source style
(**) Is in this case a source style necessary, or could one also pass in null (barring ambiguous call errors)
Q4. I executed the following snippet:
grid.ChangeCells (GridRangeInfo.Cell (0, 0), grid.BaseStylesMap["Header"].StyleInfo, StyleModifyType.Remove);
This has no effect. why?
Q5. If the answer to Q4 is: because the basestyle isn''t applied directly to the Cell level, then why do some of the ResetXXX methods work?
ex: This is one of my kludges to remove the header cell formatting:
GridStyleInfo gs = new GridStyleInfo ();
gs.BaseStyle = "Standard";
grid.ChangeCells (GridRangeInfo.Cell (0, 1), gs);
grid[0, 1].ResetHorizontalAlignment ();
Why does the ResetHorizontalAlignment() method remove the Center value set in the Column Header style?
Q6. maybe this should have been the first question ;)
What''s the correct way to remove the column / row headers from a grid?
Thanks already
>Hi Palmer,
>
>The reason is that you are misspelled the BaseStylesMap[ "standard"]( BaseStylesMap is a case sensitive). Try this code
>
>//"S" is capital in "Standard" BaseStylesMap
>grid.ChangeCells (GridRangeInfo.Cells (0,0,0,grid.ColCount), grid.BaseStylesMap["Standard"].StyleInfo, StyleModifyType.Copy);
>
>Let me know if this helps.
>Best Regards,
>Haneef
AD
Administrator
Syncfusion Team
June 29, 2006 04:54 PM UTC
Hi Palmer,
Please go through this short notes on "GridRangeStyle, ChangeCells method and precedence of style attributes".
http://www.syncfusion.com/Support/user/uploads/Short Notes_a360ab7a.zip
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
June 29, 2006 07:17 PM UTC
Hi Palmer,
You can use this code to remove the RowHeader/ColumnHeader of the grid. Here is a code snippet.
this.gridControl1.Properties.RowHeaders = false;
this.gridControl1.Properties.ColHeaders = false;
Regards,
Haneef