We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Changing cell styles

Thread ID:

Created:

Updated:

Platform:

Replies:

45770 Jun 28,2006 12:17 PM Jun 29,2006 03:17 PM Windows Forms 4
loading
Tags: GridControl
Eldritch Palmer
Asked On June 28, 2006 12:17 PM

I''ve been trying to get rid of the row & col header cells on a grid and I''m wondering why this doesn''t work. grid.ChangeCells (GridRangeInfo.Cells (0,0,0,grid.ColCount), grid.BaseStylesMap["standard"].StyleInfo, StyleModifyType.Copy); Shouldn''t this copy all of the properties of the standard style to the header cells? As it is, it doesn''t do a thing. If I explicitly assign values to a gridstyle and then call changecells, it does work, so why doesn''t it with the standard style? What am i not getting?

Administrator [Syncfusion]
Replied On June 28, 2006 12:46 PM

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

Eldritch Palmer
Replied On June 29, 2006 11:09 AM

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

Administrator [Syncfusion]
Replied On June 29, 2006 12:54 PM

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

Administrator [Syncfusion]
Replied On June 29, 2006 03:17 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;