Hi,
I am trying to create a control derived from the Ultragrid that would use a specific font by default. Here is the code for my control.
When I drag my custom on a form I can see for a brief moment that the default font I specified is used initialy but the font is then replaced by the default font of the UltraGrid.
Here is the reference on msdn : http://msdn.microsoft.com/en-us/library/53b8022e.aspx
Thanks for the help.
Here is the code :
using System;using System.Collections.Generic;using System.ComponentModel;using System.Drawing;using System.Data;using System.Text;using System.Windows.Forms;using Infragistics.Win.UltraWinGrid;namespace Gvg.Uc.GenericCtrl{ public partial class GridTest : UltraGrid { private static System.Drawing.Font _defaultFont = new System.Drawing.Font("Tahoma", 16.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 178, false); public GridTest() { InitializeComponent(); //Font = _defaultFont; } public override Font Font { // Note that the MyFont property never // returns null. get { if (_defaultFont != null) return _defaultFont; if (Parent != null) return Parent.Font; return DefaultFont; } set { _defaultFont = value; } } public bool ShouldSerializeFont() { return _defaultFont != null; } public override void ResetFont() { _defaultFont = null; } }}
Thanks. Thats great.
When you first place a WinGrid on a form, we apply a default preset called "Infragistics Standard". This is likely overwriting the font you've put in your inherited control's constructor, at least by overwriting .
You can change the preset that gets applied by default to every WinGrid you add to a form. You could either point this to a preset that simply doesn't overwrite your chosen font, or to a preset that uses your desired font by default. To do so, click on the Start button that shows on any WinGrid in the designer, go to "Presets," and then go to "Manage Presets". You'll find a checkbox that says "Apply this Preset to Grids created at design time". You can either clear this checkbox to no longer apply a particular preset ("Infragistics Standard" is applied by default), or check it to apply one or more other presets whenever a WinGrid is added to a form at design-time. Any changes you make here are written to your system registry, so they'll affect any WinGrid you add in the future.