How to change the default font of form controls in Visual Studio IDE

I would like to set the default font of form components from Microsoft Sans Serif to MS Outlook

I can change the font every time I install a new control on the form, but its time is time consuming. I did not find any help or options for it in Visual Studio 2012.

How can I change the default font for any added control?

+2
fonts visual-studio winforms
source share
2 answers

Many controls that you add to a form by default use some form properties. This includes Font forms, as well as its BackColor . This is convenient if you want to use, for example, Consolas,10 for all controls.

Here is the MSDN on these 'ambient properties' .:

The ambient property is a property of the control; if it is not set, it is retrieved from the parent control. If the control does not have a parent and the property is not set, the control tries to find the value of the ambient property through the Site property. If the control is not specified, the site does not support surrounding properties, or the property is not set on the AmbientProperties object, the control uses its own default values. Some objects derived from a control class may set the property, even if you do not. For example, the class form always sets the ForeColor and BackColor properties.

TextBoxes and some other controls do not get BackColor .

Note. Changing the font of the form will change these "inherited" fonts of all the controls on the form, including text fields, lists, etc. Those properties that you set directly will not change.

So: if you want to use different fonts, first get the font of the form first and try to avoid an uncontrolled combination of default values ​​and set values! (You can check what you installed in the From.Designer.cs .. file)

+4
source share

I have the same question that bothers me very much, and I can’t find a solution for several months. Today I finally found a possible solution using my limited concepts in C #.

Go back to the topic, just add the two lines below to the file " form1.designer.cs ", which is located in the visual studio installation directory. My visual studio 2010 has this directory: C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ IDE \ ProjectTemplatesCache \ CSharp \ Windows \ 1033 \ WindowsApplication.zip

 using System.Drawing; ///this line on top of all this.Font = new Font("Arial", 16); ///this line in the InitializeComponent() 

There are some side effects, because some properties depend on the font size, for example, the size of the form will increase due to the AutoScaleMode form, the size of the button / text field is not suitable by default, as you know ... But this is not a big question. A good programmer could solve this problem on his own.
Thus, you can change something, for example, the font of the button / layout, color ... It all depends on your imagination.
This is my first post. Hope this helps some guys like me.

0
source share

All Articles