【问题标题】:How to bring up Color Picker Pallete C#如何调出 Color Picker Pallete C#
【发布时间】:2014-05-04 09:50:21
【问题描述】:

这就是我想要执行的操作: 用户从背景颜色菜单中选择一种颜色。这会调出调色板,用户选择自定义 RGB 颜色,该颜色将是新的textboxMain.BackColor

【问题讨论】:

    标签: c# colors textbox


    【解决方案1】:

    来自微软ColorDialog Class

    private void button1_Click(object sender, System.EventArgs e)
    {
        ColorDialog MyDialog = new ColorDialog();
        // Keeps the user from selecting a custom color.
        MyDialog.AllowFullOpen = false;
        // Allows the user to get help. (The default is false.)
        MyDialog.ShowHelp = true;
        // Sets the initial color select to the current text color.
        MyDialog.Color =  textboxMain.BackColor;
    
        // Update the text box color if the user clicks OK  
        if (MyDialog.ShowDialog() == DialogResult.OK)
             textboxMain.BackColor =  MyDialog.Color;
    }
    

    【讨论】:

    • 谢谢,这对我有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-09
    • 2020-08-01
    • 1970-01-01
    相关资源
    最近更新 更多