Mega Code Archive

 
Categories / C# Tutorial / GUI Windows Forms
 

Auto Scale Button

using System; using System.Drawing; using System.Windows.Forms; class MyClass: Form {     [STAThread]     public static void Main()     {         Application.EnableVisualStyles();         Application.Run(new MyClass());     }     public MyClass()     {         ClientSize = new Size(240, 80);         Button btn = new Button();         btn.Parent = this;         btn.Text = "good!";         btn.Size = new Size(17 * 4, 14);         btn.Location = new Point((ClientSize.Width - btn.Width) / 2,                                  (ClientSize.Height - btn.Height) / 2);         AutoScaleDimensions = new Size(4, 8);         AutoScaleMode = AutoScaleMode.Font;     } }