Hình mẫu :
Click vào hình ảnh để lấy hình ảnh lớn

Tên:		fa.png
Lần xem:	4
Size:		9.0 KB
ID:		5071

Source

Visual C# Code:
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7.  
  8. namespace Anchor
  9. {
  10.   /// <summary>
  11.   /// Summary description for Form1.
  12.   /// </summary>
  13.   public class FormAnchor : System.Windows.Forms.Form
  14.   {
  15.     private System.Windows.Forms.Button btnOK;
  16.     private System.Windows.Forms.Button btnCancel;
  17.     private System.Windows.Forms.TextBox textBox1;
  18.     private System.Windows.Forms.Button btnClear;
  19.     private System.Windows.Forms.CheckBox checkBox1;
  20.     private System.Windows.Forms.CheckBox checkBox2;
  21.     private System.Windows.Forms.CheckBox checkBox3;
  22.     private System.Windows.Forms.RadioButton radioButton1;
  23.     private System.Windows.Forms.RadioButton radioButton2;
  24.     /// <summary>
  25.     /// Required designer variable.
  26.     /// </summary>
  27.     private System.ComponentModel.Container components = null;
  28.  
  29.     public FormAnchor()
  30.     {
  31.       //
  32.       // Required for Windows Form Designer support
  33.       //
  34.       InitializeComponent();
  35.  
  36.       //
  37.       // TODO: Add any constructor code after InitializeComponent call
  38.       //
  39.     }
  40.  
  41.     /// <summary>
  42.     /// Clean up any resources being used.
  43.     /// </summary>
  44.     protected override void Dispose( bool disposing )
  45.     {
  46.       if( disposing )
  47.       {
  48.         if (components != null)
  49.         {
  50.           components.Dispose();
  51.         }
  52.       }
  53.       base.Dispose( disposing );
  54.     }
  55.  
  56.     #region Windows Form Designer generated code
  57.     /// <summary>
  58.     /// Required method for Designer support - do not modify
  59.     /// the contents of this method with the code editor.
  60.     /// </summary>
  61.     private void InitializeComponent()
  62.     {
  63.       this.btnOK = new System.Windows.Forms.Button();
  64.       this.btnCancel = new System.Windows.Forms.Button();
  65.       this.textBox1 = new System.Windows.Forms.TextBox();
  66.       this.btnClear = new System.Windows.Forms.Button();
  67.       this.checkBox1 = new System.Windows.Forms.CheckBox();
  68.       this.checkBox2 = new System.Windows.Forms.CheckBox();
  69.       this.checkBox3 = new System.Windows.Forms.CheckBox();
  70.       this.radioButton1 = new System.Windows.Forms.RadioButton();
  71.       this.radioButton2 = new System.Windows.Forms.RadioButton();
  72.       this.SuspendLayout();
  73.       //
  74.       // btnOK
  75.       //
  76.       this.btnOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
  77.       this.btnOK.Location = new System.Drawing.Point(106, 188);
  78.       this.btnOK.Name = "btnOK";
  79.       this.btnOK.Size = new System.Drawing.Size(72, 32);
  80.       this.btnOK.TabIndex = 0;
  81.       this.btnOK.Text = "Bottom";
  82.       //
  83.       // btnCancel
  84.       //
  85.       this.btnCancel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
  86.       this.btnCancel.Location = new System.Drawing.Point(196, 188);
  87.       this.btnCancel.Name = "btnCancel";
  88.       this.btnCancel.Size = new System.Drawing.Size(72, 32);
  89.       this.btnCancel.TabIndex = 1;
  90.       this.btnCancel.Text = "Bottom Right";
  91.       //
  92.       // textBox1
  93.       //
  94.       this.textBox1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  95.         | System.Windows.Forms.AnchorStyles.Left)
  96.         | System.Windows.Forms.AnchorStyles.Right);
  97.       this.textBox1.Location = new System.Drawing.Point(72, 80);
  98.       this.textBox1.Multiline = true;
  99.       this.textBox1.Name = "textBox1";
  100.       this.textBox1.Size = new System.Drawing.Size(140, 60);
  101.       this.textBox1.TabIndex = 2;
  102.       this.textBox1.Text = "Top Bottom Left Right";
  103.       //
  104.       // btnClear
  105.       //
  106.       this.btnClear.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
  107.       this.btnClear.Location = new System.Drawing.Point(16, 188);
  108.       this.btnClear.Name = "btnClear";
  109.       this.btnClear.Size = new System.Drawing.Size(72, 32);
  110.       this.btnClear.TabIndex = 3;
  111.       this.btnClear.Text = "Bottom Left";
  112.       //
  113.       // checkBox1
  114.       //
  115.       this.checkBox1.Location = new System.Drawing.Point(16, 8);
  116.       this.checkBox1.Name = "checkBox1";
  117.       this.checkBox1.Size = new System.Drawing.Size(56, 24);
  118.       this.checkBox1.TabIndex = 4;
  119.       this.checkBox1.Text = "Top Left";
  120.       //
  121.       // checkBox2
  122.       //
  123.       this.checkBox2.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
  124.       this.checkBox2.Location = new System.Drawing.Point(228, 8);
  125.       this.checkBox2.Name = "checkBox2";
  126.       this.checkBox2.Size = new System.Drawing.Size(64, 24);
  127.       this.checkBox2.TabIndex = 5;
  128.       this.checkBox2.Text = "Top Right";
  129.       //
  130.       // checkBox3
  131.       //
  132.       this.checkBox3.Anchor = System.Windows.Forms.AnchorStyles.Top;
  133.       this.checkBox3.Location = new System.Drawing.Point(106, 8);
  134.       this.checkBox3.Name = "checkBox3";
  135.       this.checkBox3.Size = new System.Drawing.Size(80, 24);
  136.       this.checkBox3.TabIndex = 6;
  137.       this.checkBox3.Text = "Top";
  138.       //
  139.       // radioButton1
  140.       //
  141.       this.radioButton1.Anchor = System.Windows.Forms.AnchorStyles.Left;
  142.       this.radioButton1.Location = new System.Drawing.Point(8, 82);
  143.       this.radioButton1.Name = "radioButton1";
  144.       this.radioButton1.Size = new System.Drawing.Size(48, 48);
  145.       this.radioButton1.TabIndex = 7;
  146.       this.radioButton1.Text = "Left";
  147.       //
  148.       // radioButton2
  149.       //
  150.       this.radioButton2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  151.       this.radioButton2.Location = new System.Drawing.Point(228, 82);
  152.       this.radioButton2.Name = "radioButton2";
  153.       this.radioButton2.Size = new System.Drawing.Size(56, 48);
  154.       this.radioButton2.TabIndex = 8;
  155.       this.radioButton2.Text = "Right";
  156.       //
  157.       // FormAnchor
  158.       //
  159.       this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  160.       this.ClientSize = new System.Drawing.Size(296, 245);
  161.       this.Controls.AddRange(new System.Windows.Forms.Control[] {
  162.                                       this.radioButton2,
  163.                                       this.radioButton1,
  164.                                       this.checkBox3,
  165.                                       this.checkBox2,
  166.                                       this.checkBox1,
  167.                                       this.btnClear,
  168.                                       this.textBox1,
  169.                                       this.btnCancel,
  170.                                       this.btnOK});
  171.       this.Name = "FormAnchor";
  172.       this.Text = "FormAnchor";
  173.       this.ResumeLayout(false);
  174.  
  175.     }
  176.     #endregion
  177.  
  178.     /// <summary>
  179.     /// The main entry point for the application.
  180.     /// </summary>
  181.     [STAThread]
  182.     static void Main()
  183.     {
  184.       Application.Run(new FormAnchor());
  185.     }
  186.   }
  187. }