I. Role of application. enablevisualstyles ()
Definition:
Publicstaticvoidenablevisualstyles ()
This method enables visual styles for applications. If the controls and Operating Systems Support visual styles, the controls are drawn in visual styles. To enablevisualstyles take effect, you must call it before creating any control in the application. enablevisualstyles is usually the first line of the main function.
When you call enablevisualstyles, you can enable the visual style without a separate list.
[STAThread]static void Main(){ Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false) Application.Run(new Form1());}
To put it simply, let your controls (including forms) be displayed. If you build a winform program, don't call it and try to see what the result will be.
2. What does application. setcompatibletextrenderingdefault (false) mean? The main idea is as follows:
1. Purpose: Set the default mode for displaying the control text within the application scope (it can be set to use the new GDI + or the old GDI)
True: displays text in the mode of GDI +,
False: displays text in GDI mode.
2. You can only call this method in a program that runs the form separately. You cannot call this method in a plug-in program.
3. This method can only be called before the program creates any form. Otherwise, an invalidoperationexception occurs.