Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple d’utilisation des ‘Anchor’ et ‘Dock’

Exemple,d'utilisation,des,'Anchor',et,'Dock'
{filelink=14633}

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
 
class ExempleCompletAnchor : System.Windows.Forms.Form {
 
    public ExempleCompletAnchor() {
        InitializeComponent();
        CenterToScreen();
    }
 
    protected void dockNone_Click(object sender, System.EventArgs e) {
        btn1.Dock = DockStyle.None;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void dockFill_Click(object sender, System.EventArgs e) {
        btn1.Dock = DockStyle.Fill;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void dockRight_Click(object sender, System.EventArgs e) {
        btn1.Dock = DockStyle.Right;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void dockLeft_Click(object sender, System.EventArgs e) {
        btn1.Dock = DockStyle.Left;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void dockBottom_Click(object sender, System.EventArgs e) {
        btn1.Dock = DockStyle.Bottom;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void dockTop_Click(object sender, System.EventArgs e) {
        btn1.Dock = DockStyle.Top;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void ancRight_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Right;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void ancBottom_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Bottom;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void ancLeft_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Left;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    protected void ancTop_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Top;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    private void ancNone_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.None;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    private void ancTopLeft_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    private void ancTopRight_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    private void ancBotLeft_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    private void ancBotRight_Click(object sender, System.EventArgs e) {
        btn1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
        btn1.Text = "Anchor: " + btn1.Anchor.ToString() +
            "
Dock: " + btn1.Dock.ToString();
    }
 
    private void InitializeComponent() {
        this.dockRight = new System.Windows.Forms.MenuItem();
        this.dockBottom = new System.Windows.Forms.MenuItem();
        this.ancNone = new System.Windows.Forms.MenuItem();
        this.ancTopLeft = new System.Windows.Forms.MenuItem();
        this.ancTop = new System.Windows.Forms.MenuItem();
        this.dockFill = new System.Windows.Forms.MenuItem();
        this.mnuMainMenu = new System.Windows.Forms.MainMenu();
        this.mnuAnchor = new System.Windows.Forms.MenuItem();
        this.ancLeft = new System.Windows.Forms.MenuItem();
        this.ancBottom = new System.Windows.Forms.MenuItem();
        this.ancRight = new System.Windows.Forms.MenuItem();
        this.ancTopRight = new System.Windows.Forms.MenuItem();
        this.ancBotLeft = new System.Windows.Forms.MenuItem();
        this.ancBotRight = new System.Windows.Forms.MenuItem();
        this.mnuDock = new System.Windows.Forms.MenuItem();
        this.dockTop = new System.Windows.Forms.MenuItem();
        this.dockLeft = new System.Windows.Forms.MenuItem();
        this.dockNone = new System.Windows.Forms.MenuItem();
        this.btn1 = new System.Windows.Forms.Button();
        this.SuspendLayout();
        this.dockRight.Index = 3;
        this.dockRight.Text = "Right";
        this.dockRight.Click += new System.EventHandler(this.dockRight_Click);
        this.dockBottom.Index = 1;
        this.dockBottom.Text = "Bottom";
        this.dockBottom.Click += new System.EventHandler(this.dockBottom_Click);
        this.ancNone.Index = 4;
        this.ancNone.Text = "None";
        this.ancNone.Click += new System.EventHandler(this.ancNone_Click);
        this.ancTopLeft.Index = 5;
        this.ancTopLeft.Text = "TopLeft";
        this.ancTopLeft.Click += new System.EventHandler(this.ancTopLeft_Click);
        this.ancTop.Index = 0;
        this.ancTop.Text = "Top";
        this.ancTop.Click += new System.EventHandler(this.ancTop_Click);
        this.dockFill.Index = 4;
        this.dockFill.Text = "Fill";
        this.dockFill.Click += new System.EventHandler(this.dockFill_Click);
        this.mnuMainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.mnuAnchor,
            this.mnuDock});
 
        this.mnuAnchor.Index = 0;
        this.mnuAnchor.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.ancTop,
            this.ancLeft,
            this.ancBottom,
            this.ancRight,
            this.ancNone,
            this.ancTopLeft,
            this.ancTopRight,
            this.ancBotLeft,
            this.ancBotRight});
        this.mnuAnchor.Text = "Anchor Value";
        this.ancLeft.Index = 1;
        this.ancLeft.Text = "Left";
        this.ancLeft.Click += new System.EventHandler(this.ancLeft_Click);
        this.ancBottom.Index = 2;
        this.ancBottom.Text = "Bottom";
        this.ancBottom.Click += new System.EventHandler(this.ancBottom_Click);
        this.ancRight.Index = 3;
        this.ancRight.Text = "Right";
        this.ancRight.Click += new System.EventHandler(this.ancRight_Click);
        this.ancTopRight.Index = 6;
        this.ancTopRight.Text = "TopRight";
        this.ancTopRight.Click += new System.EventHandler(this.ancTopRight_Click);
        this.ancBotLeft.Index = 7;
        this.ancBotLeft.Text = "BottomLeft";
        this.ancBotLeft.Click += new System.EventHandler(this.ancBotLeft_Click);
        this.ancBotRight.Index = 8;
        this.ancBotRight.Text = "BottomRight";
        this.ancBotRight.Click += new System.EventHandler(this.ancBotRight_Click);
        this.mnuDock.Index = 1;
        this.mnuDock.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.dockTop,
            this.dockBottom,
            this.dockLeft,
            this.dockRight,
            this.dockFill,
            this.dockNone});
        this.mnuDock.Text = "Dock Value";
        this.dockTop.Index = 0;
        this.dockTop.Text = "Top";
        this.dockTop.Click += new System.EventHandler(this.dockTop_Click);
        this.dockLeft.Index = 2;
        this.dockLeft.Text = "Left";
        this.dockLeft.Click += new System.EventHandler(this.dockLeft_Click);
        this.dockNone.Index = 5;
        this.dockNone.Text = "None";
        this.dockNone.Click += new System.EventHandler(this.dockNone_Click);
        this.btn1.Location = new System.Drawing.Point(8, 16);
        this.btn1.Name = "btn1";
        this.btn1.Size = new System.Drawing.Size(120, 40);
        this.btn1.TabIndex = 0;
        this.btn1.Text = "Cliquez ici";
        this.ClientSize = new System.Drawing.Size(480, 155);
        this.Controls.Add(this.btn1);
        this.Menu = this.mnuMainMenu;
        this.Name = "ExempleCompletAnchor";
        this.Text = "Exemple Complet Anchor";
        this.ResumeLayout(false);
    }
 
    private System.Windows.Forms.MenuItem dockNone;
    private System.Windows.Forms.MenuItem dockFill;
    private System.Windows.Forms.MenuItem dockRight;
    private System.Windows.Forms.MenuItem dockLeft;
    private System.Windows.Forms.MenuItem dockBottom;
    private System.Windows.Forms.MenuItem dockTop;
    private System.Windows.Forms.MenuItem mnuDock;
    private System.Windows.Forms.Button btn1;
    private System.Windows.Forms.MenuItem ancRight;
    private System.Windows.Forms.MenuItem ancBottom;
    private System.Windows.Forms.MenuItem ancLeft;
    private System.Windows.Forms.MenuItem ancTop;
    private System.Windows.Forms.MenuItem mnuAnchor;
    private System.Windows.Forms.MenuItem ancNone;
    private System.Windows.Forms.MenuItem ancTopLeft;
    private System.Windows.Forms.MenuItem ancBotRight;
    private System.Windows.Forms.MenuItem ancBotLeft;
    private System.Windows.Forms.MenuItem ancTopRight;
    private System.Windows.Forms.MainMenu mnuMainMenu;
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.Run(new ExempleCompletAnchor());
    }
}

No comments yet.

Leave a Comment