C#-TrackBar-RGB颜色窗体背景色,动态加载颜色效果,通过Trackbar设置,值255.---ShinePans

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

namespace 设置窗体颜色_TrackBar_
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = trackBar1.Value.ToString();
            textBox2.Text = trackBar2.Value.ToString();
            textBox3.Text = trackBar3.Value.ToString();
            this.BackColor = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value);
            
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            textBox1.Text = trackBar1.Value.ToString();
            Form1 frm = this;
            frm.BackColor =  Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value);
        }

        private void trackBar2_Scroll(object sender, EventArgs e)
        {
            textBox2.Text = trackBar2.Value.ToString();
            Form1 frm = this;
            frm.BackColor = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value);
        }

        private void trackBar3_Scroll(object sender, EventArgs e)
        {
            textBox3.Text = trackBar3.Value.ToString();
            Form1 frm = this;
            frm.BackColor = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value);
        }
    }
}



通过 FromArgb  0-255 的数值来设置颜色 ,加入了 TrackBar, 我想到了 win 8安装时 那个颜色渐变,就是采用这个原理,可以马上做一个.


接下来会做一个


效果及 源码:



C#-TrackBar-RGB颜色窗体背景色,动态加载颜色效果,通过Trackbar设置,值255.---ShinePans_第1张图片


http://yunpan.cn/csJwjgxLF65rD  提取码 b1a5

你可能感兴趣的:(C#)