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 system colors on window controls using .net 2.0.

Author: Zunnair
Download Source Code : 823_SystemColorsApp.zip

In this simple article you will learn that how to use apply system colors on window controls.

 Create new c# project. Drag four buttons and one label on the windows form.

 

Now write following code on form load event:

 

C#

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "System colors Apps";

            label1.Text = " ..This label for testing.. ";

            label1.Dock = DockStyle.Top;

            label1.BackColor = System.Drawing.Color.Yellow;

 

            button1.Text = "Red";

            button2.Text = "Blue";

            button3.Text = "Orange";

            button4.Text = "White";

        }

 

VB

 

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

        Me.Text = "System colors Apps"

        label1.Text = " ..This label for testing.. "

        label1.Dock = DockStyle.Top

        label1.BackColor = System.Drawing.Color.Yellow

 

        button1.Text = "Red"

        button2.Text = "Blue"

        button3.Text = "Orange"

        button4.Text = "White"

    End Sub

 

 

Now write code on buttons events

 

C#

 

private void button1_Click(object sender, EventArgs e)

        {

            label1.BackColor = System.Drawing.Color.Red;

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            label1.BackColor = System.Drawing.Color.Blue;

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            label1.BackColor = System.Drawing.Color.Orange;

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

            label1.BackColor = System.Drawing.Color.White;

        }

 

VB

 

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

        label1.BackColor = System.Drawing.Color.Red

    End Sub

 

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

        label1.BackColor = System.Drawing.Color.Blue

    End Sub

 

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

        label1.BackColor = System.Drawing.Color.Orange

    End Sub

 

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

        label1.BackColor = System.Drawing.Color.White

    End Sub

 

 

This is the simple code for applying system colors on windows forms controls.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Applying Docking feature on controls using .net 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net