c#中ColorDialog怎么引用绘画中

如题所述

给你三个例子参考灵活使用,网址里面有个例子.

public partial class Form1 : Form
    {
        ColorDialog 选择颜色 = new ColorDialog();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            /*c#中ColorDialog怎么引用绘画中http://msdn.microsoft.com/zh-cn/library/system.windows.forms.colordialog(v=vs.110).aspx*/
            选择颜色.AllowFullOpen = false;
            选择颜色.ShowHelp = true;
            选择颜色.Color = this.ForeColor;
            if (选择颜色.ShowDialog() == DialogResult.OK)
                this.ForeColor = 选择颜色.Color;

   }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Pen 线条颜色 = new Pen(选择颜色.Color, 1);
            e.Graphics.DrawEllipse(线条颜色, new RectangleF(42, 42, this.Height / 2, this.Height / 2));/*圆*/
        }

温馨提示:答案为网友推荐,仅供参考
相似回答