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
 

Applying Docking feature on controls using .net 2.0.

Author: Zunnair
Download Source Code : 822_DockApp.zip

In this simple article you will learn that how to use apply docking feature on controls.

 Create new c# project. Drag five buttons on the windows form.

 

Now write following code on form load event:

 

C#

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp Docking APPs";

 

            button1.Text = "Top";

            button2.Text = "Left";

            button3.Text = "Right";

            button4.Text = "Bottom";

            button5.Text = "Default";

        }

 

VB

 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "DevAsp Docking APPs"

 

        button1.Text = "Top"

        button2.Text = "Left"

        button3.Text = "Right"

        button4.Text = "Bottom"

        button5.Text = "Default"

    End Sub

 

Now write code on buttons events

 

C#

 

private void button1_Click(object sender, EventArgs e)

        {

            button1.Dock = DockStyle.Top;

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            button2.Dock = DockStyle.Left;

 

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

            button4.Dock = DockStyle.Bottom;

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            button3.Dock = DockStyle.Right;

        }

 

        private void button5_Click(object sender, EventArgs e)

        {

            button1.Dock = DockStyle.None;

            button2.Dock = DockStyle.None;

            button3.Dock = DockStyle.None;

            button4.Dock = DockStyle.None;

        }

 

VB

 

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        button1.Dock = DockStyle.Top

    End Sub

 

    Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)

        button2.Dock = DockStyle.Left

 

    End Sub

 

    Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)

        button4.Dock = DockStyle.Bottom

    End Sub

 

    Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs)

        button3.Dock = DockStyle.Right

    End Sub

 

    Private Sub button5_Click(ByVal sender As Object, ByVal e As EventArgs)

        button1.Dock = DockStyle.None

        button2.Dock = DockStyle.None

        button3.Dock = DockStyle.None

        button4.Dock = DockStyle.None

    End Sub

 

This is the simple code for Docking windows forms controls.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Use Anchoring feature in window forms on controls using .net 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net