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 BaseStyle in Realtime

Thread ID:

Created:

Updated:

Platform:

Replies:

11358 Mar 3,2004 08:47 AM Mar 3,2004 11:42 AM Windows Forms 2
loading
Tags: GridControl
Aaron Jackson
Asked On March 3, 2004 08:47 AM

Greetings, Excuse my post if it seems a bit simplistic, I''m new to this toolkit. My application sets up a number of BaseStyles that represent my formatting options. The application runs fine the first time through the configuration code block and generates the right StyleInfo (as I can see it displaying properly in the application). Later, I change some "configurable" items and try to apply them to the base styles and I get a NullReferenceException. I cant see that I''m doing anything odd, but here is the code block (it is used the first time [which works] and second time [which fails]). PreferencesModel model = AppMain.AppPreferencesModel ; PreferencesModel.FormatState format_state = model.Format ; m_dataGrid.BeginUpdate() ; foreach( DictionaryEntry entry in format_state.Attributes ) { Rule rule = entry.Key as Rule ; FormatAttributes attributes = entry.Value as FormatAttributes ; Font font = attributes.Font ; string ident = rule.m_filter.Ident ; GridBaseStyle base_style = m_dataGrid.BaseStylesMap[ ident ] ; GridFontInfo font_info = new GridFontInfo() ; font_info.Bold = font.Bold ; font_info.Italic = font.Italic ; font_info.Facename = font.FontFamily.Name ; font_info.Size = font.Size ; font_info.Strikeout = font.Strikeout ; font_info.Underline = font.Underline ; base_style.StyleInfo.BeginUpdate() ; base_style.StyleInfo.BackColor = attributes.Background ; base_style.StyleInfo.TextColor = attributes.Foreground ; base_style.StyleInfo.Font = font_info ; base_style.StyleInfo.EndUpdate() ; } m_dataGrid.Model.ResetVolatileData() ; m_dataGrid.EndUpdate() ; Here is the exception: System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Styles.StyleInfoStore.get_IsEmpty() at Syncfusion.Styles.StyleInfoBase.get_IsEmpty() at Syncfusion.Styles.StyleInfoIdentityBase.GetBaseStyleNotEmptyExpandable(IStyleInfo thisStyleInfo, StyleInfoProperty sip) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.get_GdipFont() at Syncfusion.Windows.Forms.Grid.GridStaticCellRenderer.OnDraw(Graphics g, Rectangle clientRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.Draw(Graphics g, Rectangle cellRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridStaticCellRenderer.Draw(Graphics g, Rectangle cellRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) at Syncfusion.Windows.Forms.Grid.GridControlBase.OnDrawItem(Graphics g, Int32 rowIndex, Int32 colIndex, Rectangle rectItem, GridStyleInfo style) catched at Syncfusion.Windows.Forms.Grid.GridControlBase.OnDrawItem(Graphics g, Int32 rowIndex, Int32 colIndex, Rectangle rectItem, GridStyleInfo style) in :line 0 catched at Syncfusion.Windows.Forms.Grid.GridControlBase.OnDrawItem(Graphics g, Int32 rowIndex, Int32 colIndex, Rectangle rectItem, GridStyleInfo style) in :line 0

Administrator [Syncfusion]
Replied On March 3, 2004 11:18 AM

Instead of GridFontInfo font_info = new GridFontInfo(); try using GridFontInfo font_info = base_style.StyleInfo.Font; Ie., modify the fontinfo object present in the basestyle, and not set a new (almost empty with a some default properties set) that loses some ID settings.

Aaron Jackson
Replied On March 3, 2004 11:42 AM

Thank you for the quick response, that fixed my issue.

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.

;