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. Image for the cookie policy date

Inheriting from Grid Control

What is the recomended way of creating a Base Grid which has a series of BaseStyles, Context menu's, etc already defined. do we just inherit a base class from the Syncfusion gridControl and define all of these things there? I have tried this already, and when i add a derived grid to a form, it copies any styles that i have in my base class into the initialise component of the form, however, if i subsequently add a style to the base class, the derived class will not automatically pick up the new style. Thanks Trevor Trev

1 Reply

AD Administrator Syncfusion Team September 29, 2003 02:25 PM

Hi Trev, Call InitBaseStyles(); from your derived grid ctor. That InitBaseStyles method could look as follows: internal void InitBaseStyles() { if (!BaseStylesMap.Modified) { GridStyleInfo style = BaseStylesMap["Row Header"].StyleInfo; style = BaseStylesMap["Standard"].StyleInfo; style.CheckBoxOptions.CheckedValue = "True"; style.CheckBoxOptions.UncheckedValue = "False"; style.Font.Facename = "Tahoma"; style.Font.Size = 8; style.WrapText = true; style.AllowEnter = false; style = BaseStylesMap["Row Header"].StyleInfo; style.CellType = "RowHeaderCell"; style.Enabled = false; style = BaseStylesMap["Column Header"].StyleInfo; style.Enabled = false; style.CellType = "ColumnHeaderCell"; style.Font.Bold = false; style = BaseStylesMap["Summary"].StyleInfo; //style.Font.Bold = false; style.BackColor = SystemColors.Info; style.TextColor = SystemColors.InfoText; style.Enabled = false; style.CellType = "Static"; style.Borders.Right = GridBorder.Empty; style.Borders.Top = new GridBorder(GridBorderStyle.Solid, Color.Blue, GridBorderWeight.Medium); ... BaseStylesMap.Modified = false; } } The key point is that you have to set BaseStylesMap.Modified = false; That way the designer will know the base styles have not been touched by the user. Another key point is that you check for BaseStylesMap.Modified at the beginning of InitBaseStyles. That is important if you deserialize your grid document using runtime serialization from a file or binary stream because in that case you do not want override the settings that were loaded from the SerializationInfo document. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon