Panel and form dock pad : Panel « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » GUI Windows Form » Panel 




Panel and form dock pad
Panel and form dock pad

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

public class Form1 : Form
{
  private System.Windows.Forms.GroupBox GroupBox1;
  private System.Windows.Forms.Button cmdUpdate;
  private System.Windows.Forms.NumericUpDown udDockPaddingForm;
  private System.Windows.Forms.NumericUpDown udDockPaddingPanel;
  private System.Windows.Forms.ComboBox lstDockPanel;
  private System.Windows.Forms.Label Label3;
  private System.Windows.Forms.Label Label4;
  private System.Windows.Forms.ComboBox lstDockTextBox;
  private System.Windows.Forms.Label Label2;
  private System.Windows.Forms.Label Label1;
  private System.Windows.Forms.Panel pnlDock;
  private System.Windows.Forms.TextBox txtDock;

  public Form1() {
        InitializeComponent();
        lstDockPanel.Items.AddRange(Enum.GetNames(Dock.GetType()));
      lstDockTextBox.Items.AddRange(Enum.GetNames(Dock.GetType()));

      lstDockPanel.Text = Enum.GetName(Dock.GetType(), pnlDock.Dock);
      lstDockTextBox.Text = Enum.GetName(Dock.GetType(), lstDockTextBox.Dock);

  }
  private void cmdUpdate_Click(object sender, EventArgs e)
  {
    this.DockPadding.All = (int)udDockPaddingForm.Value;
    pnlDock.DockPadding.All = (int)udDockPaddingPanel.Value;

    TypeConverter converter;
    converter = TypeDescriptor.GetConverter(Dock.GetType());

    pnlDock.Dock = (DockStyle)converter.ConvertFromString(lstDockPanel.Text);
    txtDock.Dock = (DockStyle)converter.ConvertFromString(lstDockTextBox.Text);

  }

  private void InitializeComponent()
  {
    this.GroupBox1 = new System.Windows.Forms.GroupBox();
    this.cmdUpdate = new System.Windows.Forms.Button();
    this.udDockPaddingForm = new System.Windows.Forms.NumericUpDown();
    this.udDockPaddingPanel = new System.Windows.Forms.NumericUpDown();
    this.lstDockPanel = new System.Windows.Forms.ComboBox();
    this.Label3 = new System.Windows.Forms.Label();
    this.Label4 = new System.Windows.Forms.Label();
    this.lstDockTextBox = new System.Windows.Forms.ComboBox();
    this.Label2 = new System.Windows.Forms.Label();
    this.Label1 = new System.Windows.Forms.Label();
    this.pnlDock = new System.Windows.Forms.Panel();
    this.txtDock = new System.Windows.Forms.TextBox();
    this.GroupBox1.SuspendLayout();
    ((System.ComponentModel.ISupportInitialize)(this.udDockPaddingForm)).BeginInit();
    ((System.ComponentModel.ISupportInitialize)(this.udDockPaddingPanel)).BeginInit();
    this.pnlDock.SuspendLayout();
    this.SuspendLayout();
    // 
    // GroupBox1
    // 
    this.GroupBox1.Controls.Add(this.cmdUpdate);
    this.GroupBox1.Controls.Add(this.udDockPaddingForm);
    this.GroupBox1.Controls.Add(this.udDockPaddingPanel);
    this.GroupBox1.Controls.Add(this.lstDockPanel);
    this.GroupBox1.Controls.Add(this.Label3);
    this.GroupBox1.Controls.Add(this.Label4);
    this.GroupBox1.Controls.Add(this.lstDockTextBox);
    this.GroupBox1.Controls.Add(this.Label2);
    this.GroupBox1.Controls.Add(this.Label1);
    this.GroupBox1.Location = new System.Drawing.Point(20220);
    this.GroupBox1.Name = "GroupBox1";
    this.GroupBox1.Size = new System.Drawing.Size(284224);
    this.GroupBox1.TabIndex = 14;
    this.GroupBox1.TabStop = false;
    this.GroupBox1.Text = "Configure";
    // 
    // cmdUpdate
    // 
    this.cmdUpdate.Location = new System.Drawing.Point(160180);
    this.cmdUpdate.Name = "cmdUpdate";
    this.cmdUpdate.Size = new System.Drawing.Size(8424);
    this.cmdUpdate.TabIndex = 10;
    this.cmdUpdate.Text = "Update";
    this.cmdUpdate.Click += new System.EventHandler(this.cmdUpdate_Click);
    // 
    // udDockPaddingForm
    // 
    this.udDockPaddingForm.Increment = new decimal(new int[] {
        5,
        0,
        0,
        0});
    this.udDockPaddingForm.Location = new System.Drawing.Point(16032);
    this.udDockPaddingForm.Name = "udDockPaddingForm";
    this.udDockPaddingForm.Size = new System.Drawing.Size(5221);
    this.udDockPaddingForm.TabIndex = 4;
    // 
    // udDockPaddingPanel
    // 
    this.udDockPaddingPanel.Increment = new decimal(new int[] {
        5,
        0,
        0,
        0});
    this.udDockPaddingPanel.Location = new System.Drawing.Point(16056);
    this.udDockPaddingPanel.Name = "udDockPaddingPanel";
    this.udDockPaddingPanel.Size = new System.Drawing.Size(5221);
    this.udDockPaddingPanel.TabIndex = 5;
    this.udDockPaddingPanel.Value = new decimal(new int[] {
        20,
        0,
        0,
        0});
    // 
    // lstDockPanel
    // 
    this.lstDockPanel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    this.lstDockPanel.FormattingEnabled = true;
    this.lstDockPanel.Location = new System.Drawing.Point(156100);
    this.lstDockPanel.Name = "lstDockPanel";
    this.lstDockPanel.Size = new System.Drawing.Size(9221);
    this.lstDockPanel.TabIndex = 8;
    // 
    // Label3
    // 
    this.Label3.Location = new System.Drawing.Point(16104);
    this.Label3.Name = "Label3";
    this.Label3.Size = new System.Drawing.Size(13620);
    this.Label3.TabIndex = 6;
    this.Label3.Text = "Dock Panel To:";
    // 
    // Label4
    // 
    this.Label4.Location = new System.Drawing.Point(16128);
    this.Label4.Name = "Label4";
    this.Label4.Size = new System.Drawing.Size(13620);
    this.Label4.TabIndex = 7;
    this.Label4.Text = "Dock TextBox To:";
    // 
    // lstDockTextBox
    // 
    this.lstDockTextBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    this.lstDockTextBox.FormattingEnabled = true;
    this.lstDockTextBox.Location = new System.Drawing.Point(156124);
    this.lstDockTextBox.Name = "lstDockTextBox";
    this.lstDockTextBox.Size = new System.Drawing.Size(9221);
    this.lstDockTextBox.TabIndex = 9;
    // 
    // Label2
    // 
    this.Label2.Location = new System.Drawing.Point(1660);
    this.Label2.Name = "Label2";
    this.Label2.Size = new System.Drawing.Size(13620);
    this.Label2.TabIndex = 3;
    this.Label2.Text = "Panel\'s DockPadding:";
    // 
    // Label1
    // 
    this.Label1.Location = new System.Drawing.Point(1636);
    this.Label1.Name = "Label1";
    this.Label1.Size = new System.Drawing.Size(13620);
    this.Label1.TabIndex = 2;
    this.Label1.Text = "Form\'s DockPadding:";
    // 
    // pnlDock
    // 
    this.pnlDock.Controls.Add(this.txtDock);
    this.pnlDock.Dock = System.Windows.Forms.DockStyle.Left;
    this.pnlDock.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.pnlDock.Location = new System.Drawing.Point(00);
    this.pnlDock.Name = "pnlDock";
    this.pnlDock.Padding = new System.Windows.Forms.Padding(20);
    this.pnlDock.Size = new System.Drawing.Size(224314);
    this.pnlDock.TabIndex = 13;
    // 
    // txtDock
    // 
    this.txtDock.Dock = System.Windows.Forms.DockStyle.Left;
    this.txtDock.Font = new System.Drawing.Font("Tahoma"8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    this.txtDock.Location = new System.Drawing.Point(2020);
    this.txtDock.Multiline = true;
    this.txtDock.Name = "txtDock";
    this.txtDock.Size = new System.Drawing.Size(108274);
    this.txtDock.TabIndex = 0;
    this.txtDock.Text = "This is a TextBox.";
    // 
    // Form1
    // 
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(497314);
    this.Controls.Add(this.GroupBox1);
    this.Controls.Add(this.pnlDock);
    this.Text = "Docking At Work";
    this.GroupBox1.ResumeLayout(false);
    ((System.ComponentModel.ISupportInitialize)(this.udDockPaddingForm)).EndInit();
    ((System.ComponentModel.ISupportInitialize)(this.udDockPaddingPanel)).EndInit();
    this.pnlDock.ResumeLayout(false);
    this.pnlDock.PerformLayout();
    this.ResumeLayout(false);
  }


  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}



           
       














Related examples in the same category
1.Subclass Panel
2.Split Container(Panel): CollapsedSplit Container(Panel): Collapsed
3.Scrollable PanelScrollable Panel
4.Scrolling Picture
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.