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.

Row/Column Styles and cell styles

Thread ID:

Created:

Updated:

Platform:

Replies:

3972 Apr 21,2003 03:22 PM Apr 23,2003 04:58 PM Windows Forms 7
loading
Tags: GridControl
Sue Harris
Asked On April 21, 2003 03:22 PM

I've noticed that if a cell has a style and the row/column style changes the cells style always overrides. For example: Cell B3 is bold, if I change column B's style to Bold and then change it to not bold, B3 is still bold. What I'm wanting to do is for the column style change to reset the individual cells for the property being changed (like Excel does it). I've been using the CellStyles sample to look at this situation. Do you have any suggestions for what I can do? Thanks, Sue

Administrator [Syncfusion]
Replied On April 21, 2003 04:32 PM

Cell styles do take precedence over column styles. If you want to set the styles in a column so they override the individual cell styles, then one way you could do it is to call ChangeCells.
GridStyleInfo style = new GridStyleInfo();
style.Font.Bold = true;
this.gridControl1.ChangeCells(GridRangeInfo.Cells(1, 2, this.gridControl1.RowCount, 2), style, Syncfusion.Styles.StyleModifyType.Override);

Sue Harris
Replied On April 22, 2003 06:18 PM

That has certainly helped, I'm now facing the situation with virtual grids that if I make that call, the SaveCellInfo event passes me the style defined by the ChangeCells call and not the resultant cell style that I had originally expected. As a result I fetch the current cell style and call ModifyStyle with the provided style and modify flag. Is this expected behaviour? Do I need to call ModifyStyle in my SaveCellInfo event for any grid which I may change a style format in that way? (If so you may want to consider making a mention of it in the event documentation as a warning to the unwary.) Thanks, Sue > Cell styles do take precedence over column styles. If you want to set the styles in a column so they override the individual cell styles, then one way you could do it is to call ChangeCells. > >
> GridStyleInfo style = new GridStyleInfo();
> style.Font.Bold = true;
> this.gridControl1.ChangeCells(GridRangeInfo.Cells(1, 2, this.gridControl1.RowCount, 2), style, Syncfusion.Styles.StyleModifyType.Override);
> 
>

Sue Harris
Replied On April 22, 2003 08:21 PM

Another question while I'm on this topic, is there a way to get a list of what properties are set in a style object? I want to be able to change my save behaviour if only certain properties are being changed, but I can't see a way (without checking all the HasXValue properties) of determining that only a certain property has changed (is set). For example: I store the cell value separately from my formatting information (partially because it doesn't get correctly set from the ParseString method), so if the formatting is the only thing to change in the style, I don't want to have to run my storing cell value code, and if the cell value is the only thing to change, I don't want to run my storing formatting code. For the cell value I can check HasCellValue, but for formatting, I have to check all of the HasValue properties that I do store. Do you have any suggestions to help? Thanks, Sue

Administrator [Syncfusion]
Replied On April 23, 2003 01:18 AM

ChangeCells does change the cell style, so SaveCellInfo will get called with the modified styles. Since you are using a virtual grid, if you want the columnstyle to override the cellstyle, then you can do so in your QueryCellInfo. Take the ColStyle and use it to modify the e.Style. This, of course, would mean that there would never be any cell specific styles (unless later in QCI you apply a setting to e.Style or unless you only apply certain of the colstyle properties to e.Style). In this manner, SaveCellInfo would not get the changed styles. You can, if you like, modify a style in SaveCellInfo so the save style differs from the original passed in style.

Sue Harris
Replied On April 23, 2003 03:06 PM

Do I misunderstand? I'm calling ChangeCells with a range, a style I just created with just the bold property set, and the ModifyType as Override (basically exactly as you posted previously). In SaveCellInfo the style I get is the style with just the bold property set. If I previously had a cell value or back color or anything else that is NOT set in the style in SaveCellInfo, and I have to call ModifyStyle. Are you saying I should be getting the modified style in SaveCellInfo? Should I be getting a style with bold, cell value and back color (if it had a cell value and back color prior to the ChangeCell call)? Thanks, Sue

Administrator [Syncfusion]
Replied On April 23, 2003 04:19 PM

In a non-virtual GridControl, yes you should be getting the fully populated style in SaveCellInfo even if you call ChangeCells with only a bold change. But in a virtual grid control, this is not the case. All the information in the style normally has to come from QueryCellInfo. ChangeCells is not triggering a QueryCellInfo so there is no chance for the full style to be set since it must come from QueryCellInfo in a virtual grid. So, I don't think ChangeCells is a good choice for your original question. Can you not use your QueryCellInfo handler to dynamically reset the bold style?

Sue Harris
Replied On April 23, 2003 04:58 PM

Ah, that clarifies it a bit better. No I don't think I can use the QueryCellInfo because if a cell style occurs after the column/row style, I want that to override. (For example, if a cell is bold, and I make the column not bold, the column style overrides the cell styles. But if the column is not bold, and I then make the cell bold, the cell overrides the column style) same data, different order of occurance. However, now that I know the issue, I think I can work around the problem by calling QueryCellInfo on all the cells in the range I'm changing and updating them then calling refresh range, rather than calling ChangeCell. This just means I have different behaviour formatting non-virtual grids and virtual grids. Thanks, Sue

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.

;