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.

Getting the actual Style for a cell

Thread ID:

Created:

Updated:

Platform:

Replies:

4549 May 18,2003 03:50 PM May 19,2003 09:18 PM Windows Forms 6
loading
Tags: GridControl
Sue Harris
Asked On May 18, 2003 03:50 PM

I would like to get a GridStyleInfo object for a cell which has the actual final style. I've tried this.gridControl.GetViewStyleInfo(rowIndex, colIndex); this.gridControl[rowIndex,colIndex]; and this.gridControl.GetCombinedStyle(GridRangeInfo.Cell( rowIndex, colIndex) ); All of them seem to only return the style for the cell. If I have a row/column or table style, the settings of these seem to be ignored. For example, if my row style backcolor is blue, my cell style still returns with a backcolor of white (HasBackColor is false) but it is painted in the grid as blue. The only way I can think of is to get the styles for the table, column and row and merging them. Is there a better way? Thanks, Sue

Administrator [Syncfusion]
Replied On May 18, 2003 06:00 PM

How are you setting the other styles? If I set this.gridControl1.ColStyles[1].BackColor = Color.Aqua; this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Bold = true; in FormLoad, then in a button handler, this code prints the expected values. Console.WriteLine(this.gridControl1[1,1].BackColor.ToString()); Console.WriteLine(this.gridControl1.BaseStylesMap["Standard"].StyleInfo.Font.Bold.ToString());

Sue Harris
Replied On May 18, 2003 11:28 PM

Sorry, I should have said this is a virtual grid. So I set the styles in the QueryCellInfo event (QueryCellInfo row = -1, col = 3) e.Style.TextColor = Blue and add a button event: Color textIsThisColor; GridStyleInfo style = this.gridControl1[2,3]; if ( style.HasTextColor ) { textIsThisColor = style.TextColor; } GridStyleInfo style1 = this.gridControl1.GetCombinedStyle(GridRangeInfo.Cell(2,3)); if ( style1.HasTextColor ) { textIsThisColor = style1.TextColor; } GridStyleInfo style2 = this.gridControl1.GetViewStyleInfo(2,3); if ( style2.HasTextColor ) { textIsThisColor = style2.TextColor; } None of the styles have the expected text color. Thanks, Sue

Administrator [Syncfusion]
Replied On May 19, 2003 01:49 AM

Comment out the check for if ( style.HasTextColor ) and I think all the ways you tried will show the Blue as the text color. The problem is that the cell style did not have TextColor explicitly set (it is inheriting it), so its style.HasTextColor was never explicitly set, and hence your code is skipping the textIsThisColor assignment. One comment is that a cell style will always appear to be fully populated since if there is not a style property explicitly set for it, it will inherit a setting from one of the parent styles (col, row, table, standard).

Sue Harris
Replied On May 19, 2003 03:30 PM

Thanks, thats seems to be the base of the problem. Does the copy constructor for GridStyleInfo ignore properties which aren't explicitly set? The actual problem is that I've got a custom TypeConverter which I'm using for displaying a limited number of the grid cells style properties (I used a sample you previously sent me). I have a class derived from GridStyleInfo: [TypeConverter(typeof(LimitedTypeConverter))] public class FormattableGridStyleInfo : Syncfusion.Windows.Forms.Grid.GridStyleInfo { public FormattableGridStyleInfo(Syncfusion.Windows.Forms.Grid.GridStyleInfo style) : base(style) { } } This class seems to lose all those non-explicitly set properties (I thought that it was never getting them, hence my original question). Is there a way to copy those non-explicitly set properties? Thanks, Sue

Administrator [Syncfusion]
Replied On May 19, 2003 06:45 PM

Hi Sue, change this line from > public FormattableGridStyleInfo(Syncfusion.Windows.Forms.Grid.GridStyleInfo style) : base(style) to > public FormattableGridStyleInfo(Syncfusion.Windows.Forms.Grid.GridStyleInfo style) : base(style.Identity, (GridStyleInfoStore) style.Store) > { > } I think that should work. The copy constructor otherwise does not initialize the "Identity" of the underlying style. Identity is needed to give the style object knowledge about the BaseStylesMap and the underlying grid. As soon as the style has its identity all properties will be able look up default values from their base style. Stefan

Sue Harris
Replied On May 19, 2003 09:18 PM

That did the trick. 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.

;