Current filter:
                                You should refresh the page.
                                  • Description:
                                    Is there any way to change the fonts of all the Xtra~ controls in a single line of code rather than having to iterate through them? Additionally, what it the best way of changing the font of the XtraGrid control?

                                    Answer:
                                    You can change the default font used by DevExpress WindowsForms controls with the following static properties:
                                    DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont - Specifies the default font of controls (except menus and toolbars).
                                    DevExpress.XtraEditors.WindowsFormsSettings.DefaultMenuFont - Specifies the default font used by menus and toolbars.
                                    DevExpress.XtraEditors.WindowsFormsSettings.DefaultPrintFont - Specifies the default text font used when printing DevExpress controls.

                                    Here is sample code that modifies the default font prior to running the main application form:

                                    [C#]
                                    [STAThread] static void Main() { DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = new Font("Courier New", 10); Application.Run(new Form1()); }
                                    [VB.NET]
                                    Public Class MainForm Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont = New Font("Courier New", 10) InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub ...

                                    If you'd like to only change a certain control's font, use the AppearanceObject.Font setting provided by the control's appearance property (typically, appearance properties have the "Appearance" sub-string in their names). Take note that some controls consist of multiple visual elements. These controls expose multiple appearance properties for all their elements. If this is the case, the font settings need to be changed across all the appearance properties provided by the control.
                                    For instance, the following code shows how to change the font of all visual elements of a GridControl's  GridView, which consist of multiple elements.

                                    [C#]
                                    using DevExpress.Utils; using DevExpress.XtraGrid.Views.Grid; void SetGridFont(GridView view, Font font) { foreach(AppearanceObject ap in view.Appearance) ap.Font = font; } // USAGE: SetGridFont(gridView1, new Font("Courier New", 10));
                                    [VB.NET]
                                    Imports DevExpress.Utils Imports DevExpress.XtraGrid.Views.Grid Sub SetGridFont(view As GridView, font As Font) Dim ap As AppearanceObject For Each ap In view.Appearance ap.Font = font Next End Sub ' USAGE: SetGridFont(GridView1, New Font("Courier New", 10))

                                    AppearanceObject objects of DevExpress controls also provide two special properties to adjust the control's font:
                                    AppearanceObject.FontSizeDelta - Specifies an integer value by which the font size is adjusted.
                                    AppearanceObject.FontStyleDelta - Specifies an additional style to be applied to the control's font.

                                    If you want to change the default font for DevExpress controls at design time, specify the font in the application settings. This technique is described in the WindowsFormsSettings.LoadApplicationSettings help topic.

                                Show all comments
                                • Matthias Wuttke 09.21.2013

                                  This is exactly what I was looking for, it helped a lot. But for creating nice-looking layouts, it would be very helpful if the new default font would be visible in the Windows Forms Designer of Visual Studio. Is this possible?

                                • Matthias Wuttke 09.21.2013

                                  Also, there are problems with right-aligned (anchored) controls; they get displaced.

                                • Yulia (DevExpress Support) 09.23.2013

                                  Hi,
                                  To avoid discussing multiple questions in a single thread, I have created separate tickets on your behalf:
                                  How to display the AppearanceObject.DefaultFont property in the Visual Studio Properties window
                                  The right-aligned controls are displayed incorrectly when the AppearanceObject.DefaultFont property value is changed
                                  We will answer you in these threads.

                                • James Gunnells 03.22.2016

                                  This helps tremendously. I might add, for beginner to maybe intermediate programmers. I thought this did not apply to my problems, because I am using controls in the designer and think that everything and all of its parts (as in the tabcontrol for example) has to be set to the desired font size. Besides being very tedious, when running a project some things were still displaced. Adding in the above does set everything to the desired font and things stay in place as they appear in the designer.
                                  Putting these two concepts together, everything goes very smoothly.
                                  Kudos!

                                • Ingvar (DevExpress Support) 03.31.2016

                                  Hi James,

                                  Thank you for sharing your results with us. We greatly appreciate it.
                                  At the same time, I want to inform you that we are working on improvements in our help resources in order to reflect all specifics.

                                  Feel free to contact us if you have any questions regarding our products.

                                • Clarence 12.12.2017

                                  Hi Guys!
                                  Just incase anyone is still in trouble with setting the design time support for appearance settings(font) i just worked out a very simple way to do it (using visual studio 2010 and 2015).

                                  1. Create a visual studio VSIX Project (tested for 2015).
                                  2. Add a VSPackage Item to you VSIX project
                                  3. Modify the VSPackage so the code looks as below:-
                                  [VB.NET]
                                  Imports System Imports System.ComponentModel.Design Imports System.Diagnostics Imports System.Drawing Imports System.Globalization Imports System.Runtime.InteropServices Imports Microsoft.VisualBasic Imports Microsoft.VisualStudio Imports Microsoft.VisualStudio.OLE.Interop Imports Microsoft.VisualStudio.Shell Imports Microsoft.VisualStudio.Shell.Interop Imports Microsoft.Win32 ''' <summary> ''' This is the class that implements the package exposed by this assembly. ''' </summary> ''' <remarks> ''' <para> ''' The minimum requirement for a class to be considered a valid package for Visual Studio ''' Is to implement the IVsPackage interface And register itself with the shell. ''' This package uses the helper classes defined inside the Managed Package Framework (MPF) ''' to do it: it derives from the Package Class that provides the implementation Of the ''' IVsPackage interface And uses the registration attributes defined in the framework to ''' register itself And its components with the shell. These attributes tell the pkgdef creation ''' utility what data to put into .pkgdef file. ''' </para> ''' <para> ''' To get loaded into VS, the package must be referred by &lt;Asset Type="Microsoft.VisualStudio.VsPackage" ...&gt; in .vsixmanifest file. ''' </para> ''' </remarks> <PackageRegistration(UseManagedResourcesOnly:=True)> <InstalledProductRegistration("#110", "#112", "1.0", IconResourceID:=400)> <Guid(DXDefaultFont.PackageGuidString)> <ProvideMenuResource("Menus.ctmenu", 1)> <ProvideAutoLoad(UIContextGuids80.DesignMode)> Public NotInheritable Class DXDefaultFont Inherits Package ''' <summary> ''' Package guid ''' </summary> Public Const PackageGuidString As String = "e402fa16-60b0-45d9-96fb-5e0ec833f89c" ''' <summary> ''' Default constructor of the package. ''' Inside this method you can place any initialization code that does not require ''' any Visual Studio service because at this point the package object is created but ''' not sited yet inside Visual Studio environment. The place to do all the other ''' initialization is the Initialize method. ''' </summary> Public Sub New() End Sub #Region "Package Members" ''' ''' Initialization of the package; this method is called right after the package is sited, so this is the place ''' where you can put all the initialization code that rely on services provided by VisualStudio. ''' Protected Overrides Sub Initialize() MyBase.Initialize() DevExpress.Utils.AppearanceObject.DefaultFont = SystemFonts.MessageBoxFont End Sub #End Region End Class
                                  4. Complie (Release configuration) and Install the extension and you are good to go. For this setup all projects will use the system font as the default font at designtime.

                                  NOTE You can change the default font to any font you like.

                                0 Solutions

                                Creation Date Importance Sort by