Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Use Dock property of controls in .net 2.0 using c#.

Author: DevAsp Team
Download Source Code : 694_dockingControls.zip

In this simple article you will learn how Use Dock property of controls.

Simply just create New Project in C#.

 

Drag one four comboBox and four Labels on the form.

 

 

Now just simply write this code on form load event

 

 

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp Docking";

 

            comboBox1.Dock = DockStyle.Left;

     

      comboBox4.Dock = DockStyle.Right;

     

      comboBox2.Dock = DockStyle.None;

 

      comboBox3.Dock = DockStyle.None;

 

            label2.Text = "Dock Property Left";

                 

label1.Text = "Dock Property Right";

 

button1.Text = "Change Dock Settings";

 

            button2.Text = "Default";

        }

 

Write code on button click events

 

 

private void button1_Click(object sender, EventArgs e)

        {

            comboBox3.Dock = DockStyle.Fill ;

           

            comboBox2.Dock = DockStyle.Top ;

           

            comboBox1.Dock = DockStyle.None;

           

            comboBox4.Dock = DockStyle.None;

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            comboBox1.Dock = DockStyle.Left;

 

            comboBox4.Dock = DockStyle.Right;

 

            comboBox2.Dock = DockStyle.None;

 

            comboBox3.Dock = DockStyle.None;

        }

 

Now when u resize the form combobox1 and 4 will move with form and

other two comboboxes will not change their location.

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Get all printer installed on your machine in c# .net 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net