码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2014-10-20 13:29:20      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:c#

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安装时 那个颜色渐变,就是采用这个原理,可以马上做一个.


接下来会做一个


效果及 源码:



bubuko.com,布布扣


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

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

标签:c#

原文地址:http://blog.csdn.net/shinepan/article/details/40299395

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!