Code C#: Code Examples sample source codes

Người đăng: culaoxanh88 on Thứ Tư, 27 tháng 2, 2013


Center form window

  using System;
  using System.Drawing;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class Form1 : System.Windows.Forms.Form {
    private Button myButton; 

    public Form1()   {
      this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
      this.ClientSize = new System.Drawing.Size(320, 260);
        
            this.StartPosition=FormStartPosition.CenterScreen;
      // CenterToScreen();

      myButton = new Button();
      myButton.Text = "Superman";
      myButton.Location = new System.Drawing.Point(69, 36);
      myButton.Size = new System.Drawing.Size(140, 45);

      Controls.Add(myButton);
    }
    static void Main() {
      Application.Run(new Form1());
    }
  }

{ 0 nhận xét... read them below or add one }

Đăng nhận xét