.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Windows Application >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Set user favorite color as background color in Windows Form.

Posted By:shiv chandra       Posted Date: June 28, 2011    Points: 200    Category: Windows Application    URL: http://www.dotnetspark.com  

Basic article regarding how to set background color as per choice of user.
 

Here following two options has been provided for select color.

  1. Select Basic Color:            In basic color, color picker with basic color will be open.
  2. Select Custom Color:      Here color picker will open with custom color.

 For open color picker in Basic color mode you need to set FullOpen property of color picker dialogue box to False. If you want to open in dialogue box with full mode you need to set FullOpen property to true.

Select Basic Color


Select Custom Color

Full code of the above application

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

namespace ColorPicker
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }    

        private void btnColor_Click(object sender, EventArgs e)
        {
            colorDialog1.FullOpen = false;
            if(colorDialog1.ShowDialog() != DialogResult.Cancel)
            {
                this.BackColor = colorDialog1.Color;
            }
        }

        private void btnCustomColor_Click(object sender, EventArgs e)
        {
            colorDialog1.FullOpen = true;
            if (colorDialog1.ShowDialog() != DialogResult.Cancel)
            {
                this.BackColor = colorDialog1.Color;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend