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.

ModifyStyle

Thread ID:

Created:

Updated:

Platform:

Replies:

44356 May 22,2006 09:47 AM May 23,2006 09:15 AM Windows Forms 7
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 22, 2006 09:47 AM

Hi, i''m trying to copy one GridStyleInfo object to another GridStyleInfo object at GridDataBoundGrid at QueryCellInfo event handler of Model class. I have one object with stored style GridStyleInfo storedStyle = _stylesStore.GetStyle(e.RowIndex, e.ColIndex); And this is what is done to copy it to e.Style field of arguments of QueryCellInfo event e.Style.ModifyStyle(storedStyle.Store, Syncfusion.Styles.StyleModifyType.Copy); But for some cells - for some cells with expand buttons - this is not working - e.Style.Borders -does not get copied. Because of it we get in cell with expand button red square with "Exception" there. We have next message print at output window: System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Styles.StyleInfoStore.get_IsEmpty() in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Shared\Src\Styles\StyleInfoStore.cs:line 1096 at Syncfusion.Styles.StyleInfoBase.get_IsEmpty() in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Shared\Src\Styles\StyleInfoBase.cs:line 709 at Syncfusion.Windows.Forms.Grid.GridStyleInfo.get_ReadOnlyBorders() in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Grid\Src\GridStyleInfo.cs:line 1579 at Syncfusion.Windows.Forms.Grid.GridModel.StyleInfoBordersToMargins(GridStyleInfo style) in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Grid\Src\GridModel.cs:line 6475 at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.PerformLayout(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, Rectangle cellRectangle) in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Grid\Src\CellTypes\GridCellRendererBase.cs:line 1001 at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.Draw(Graphics g, Rectangle cellRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Grid\Src\CellTypes\GridCellRendererBase.cs:line 1101 at CQG.Matrix.CommonUI.Framework.SyncfusionGridsControls.Buttons.ExpandButton.ExpandCellRenderer.Draw(Graphics g, Rectangle cellRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) in C:\projects\CQGBasicAMPerformance\matrix2\code\CommonUI\Framework\SyncfusionGridsControls\Buttons\ExpandButton\ExpandCellRenderer.cs:line 58 at Syncfusion.Windows.Forms.Grid.GridControlBase.OnDrawItem(Graphics g, Int32 rowIndex, Int32 colIndex, Rectangle rectItem, GridStyleInfo style) in C:\projects\CleanCQGBasic\3rdPartySrc\Syncfusion\Grid\Src\GridControlBase.cs:line 2277 What is wrong - why borders are not copied? I use Syncfusion of ver.1.6.1.8. Thanks

Administrator [Syncfusion]
Replied On May 23, 2006 12:05 AM

Hi, In the grid databound rowindex = -1 and colindex = -1 represents the table style. So you should wrap your code in the QueryCellInfo by checking this. Or else the style properties that are provided in the QueryCellInfo will try to apply for the entire table and this might lead to recursive calls of the QueryCellInfo. I think this is the cause of the problem. private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { if(e.RowIndex > -1 && e.ColIndex > -1) { /// CODE /// } } Please refer to the forum thread for more details. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11358 Please let me know if this helps. Best Regards, Haneef

Administrator [Syncfusion]
Replied On May 23, 2006 05:18 AM

No, I do check for table style and for style of rows and columns - like this: private void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { if(e.RowIndex < 0 || e.ColIndex < 0) { /// CODE /// } I never set style for whole table. Never for rows, never for columns. Only for cells. No recursive calls to QueryCellInfo is done. The problem is that I have stored GridStyleInfo in which field Borders is not null and has settings for Top, Bottom, Left, Right. And e.Style also has Borders - but default ones. After this line of code for e.RowIndex = N and e.ColIndex = 1 (it is right where expand button is - for data source with more than one hierarchy level): e.Style.ModifyStyle(storedStyle.Store, Syncfusion.Styles.StyleModifyType.Copy); I get e.Style.Borders.Top or e.Style.Borders.Bottom - any of four borders - throwing exceptions. Right after I copied to e.Style.Borders style from variable of type GridStyleInfo. And funny thing is - that in depths of e.Style - somewere at Store - i see correct borders that were copied are stored. So, maybe I don''t understand you, but I think that table style is not the point here. Thanks anyway, have you any more suggestions?

Administrator [Syncfusion]
Replied On May 23, 2006 05:22 AM

also this thing does not work in copying borders e.Style.Borders = (GridBordersInfo)storedStyle.Borders.MakeCopy(e.Style, storedStyle.Borders.Sip); will continue to dig...

Administrator [Syncfusion]
Replied On May 23, 2006 06:07 AM

Hi Agneta, We tried to reproduce this issue, but could not get this issue. Maybe I am not following the steps that you are doing. Attached sample working fine here. Can you post a small sample showing this problem or tell us how to see it in the Attached sample? Here is a sample. MasterDetails.zip Could you please run this at your end and let me know how it goes? Thanks for your patience. Best Regards, Haneef

Administrator [Syncfusion]
Replied On May 23, 2006 08:08 AM

Hi, Haneef! Change your code of Model_QueryCellInfo with next - and it will begin to work as I said. Notice - check for Column # 1 - not column #3. For column #3 this excample work, for #1 - fails during grid''s drawing. private void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { if (e.ColIndex == 1 ) { style = e.Style.GetOffLineCopy(); GridBordersInfo border = new GridBordersInfo(); border.All = new GridBorder(GridBorderStyle.Solid, Color.Red); style.Borders = border; e.Style.Borders = (GridBordersInfo) style.Borders.MakeCopy(e.Style, style.Borders.Sip); e.Style.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Copy ); } } This code emulates my code. Thanks for quick response and attention!

Administrator [Syncfusion]
Replied On May 23, 2006 09:03 AM

Hi Agneta, Try this code in QueryCellInfo event. Here is a code snippet. if (e.ColIndex == 1 ) { style = new GridStyleInfo(); GridBordersInfo border = new GridBordersInfo(); border.All = new GridBorder(GridBorderStyle.Solid, Color.Red); style.Borders = border; e.Style.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override ); } If it works, I would suggest you just create a new style, set the properties you want and then use Override. I suspect there is no simple fix for the problem. Please let me know if this helps. Best Regards, Haneef

Administrator [Syncfusion]
Replied On May 23, 2006 09:15 AM

YES IT WORKS!!! Thank you very much, 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.

;