Csharp: Winform 顏色選擇器 Color convert RGB and RGB convert Color

 /// <summary>
        /// 選擇顏色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //是否選擇了顏色
            if (colorDialog1.ShowDialog(this) == DialogResult.OK)
            {
                //System.Drawing.Color.FromArgb
                this.textBox2.Text = ColorTranslator.ToHtml(colorDialog1.Color);
                this.textBoxA.Text = colorDialog1.Color.A.ToString();
                this.textBoxB.Text = colorDialog1.Color.B.ToString();
                this.textBoxG.Text = colorDialog1.Color.G.ToString();
                this.textBoxR.Text = colorDialog1.Color.R.ToString();
                this.textBoxArgb.Text = colorDialog1.Color.ToArgb().ToString();

                //1
                //this.button1.BackColor = ColorTranslator.FromHtml(this.textBox2.Text.Trim());
                //2
                //this.button1.BackColor =Color.FromArgb(int.Parse(this.textBoxArgb.Text.Trim()));
                //3
                this.button1.BackColor = Color.FromArgb(int.Parse(this.textBoxR.Text.Trim()), int.Parse(this.textBoxG.Text.Trim()), int.Parse(this.textBoxB.Text.Trim()));

            }
        }
        /// <summary>
        /// 選擇字體
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog(this) == DialogResult.OK)
            {
                this.textBox1.Text = fontDialog1.Font.ToString();
            }
        }
时间: 2024-08-24 13:32:42

Csharp: Winform 顏色選擇器 Color convert RGB and RGB convert Color的相关文章

請教一個選擇器的問題?

问题描述 $(),選擇所有class屬性為"tt2"的div對象,請問如何寫? 解决方案 $("div.tt2")抢答成功!解决方案二:测试了楼上的可用不好意思解决方案三:试试自有分晓.解决方案四:楼上的我不知道行不,但下面这个肯定行$("div[class='tt2']")

Csharp Winform TextBox 樣式以一條橫線顯示

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; using System.Reflection; using System.Runtime.InteropServices; using System.Compon

Csharp: winform PDF view control use Adobe Reader X

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; using AcroPDFLib;//引用COM組件Adobe Acrobat Browser Control Type Libra

請問怎麼才能將GRIDVIEW中的數據導到EXCEL並由用戶選擇路徑存入客戶端,並在字符型或所有字段值前加入單引號?

问题描述 求救:我現在用C#寫了幾段代碼都無法解決這個問題!如果用數據流存儲,會出現如果字符串類型的數據導入EXCEL前面的001會直接變為1而用EXCEL存儲,不會有存儲框提示,自動存在了WEB服務器上,也沒任何提示!如何才能讓用戶選擇性存儲到客戶端?多謝方式一:文件流形式(但不能解決0開台的字串問題)protectedvoidGridViewToExcel(GridViewGdv,stringstitle){Response.Clear();Response.Buffer=true;Resp

文本框文字顏色問題

问题描述 請教一下,這段是不是哪裡寫錯了,為何界面上,死活就是黑色的,不會變顏色Ifdatatable1.Rows.Count>0ThenSelectCasedatatable1.Rows(0).Item(0)Case"1"TxtF009.Text="合格"TxtF009.ForeColor=Drawing.Color.GreenCase"0"TxtF009.Text="不合格"TxtF009.ForeColor=Dra

編程 未來-已決定要選擇C/C++當我的主要語言,該如何使用他們增加編程的技術呢???

问题描述 已決定要選擇C/C++當我的主要語言,該如何使用他們增加編程的技術呢??? 基礎可說是打好了,但是由 進階->深入 這個過程似乎非常模糊,看完一些MFC,windowsAPI和C語言的網路編程之後,感覺編程並沒有太大的進步.....請高手指引

WPF:将HTML RGB颜色值转化为Color对象的两种方式

原文:WPF:将HTML RGB颜色值转化为Color对象的两种方式  (1)方式一: Color color1 = (Color)System.Windows.Media.ColorConverter.ConvertFromString("#E0E0E0"); (2)方式二: Color color2 = ConvertToColor("#E0E0E0"); public static System.Windows.Media.Color ConvertToCol

Csharp 打印Word文件默認打印機設置或選擇打印機設置代碼

//打印文檔 object nullobj = Missing.Value; //aDoc = wordApp.Documents.Open(ref file, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, /

datalist中怎麼根據時間改變table的背景顏色

问题描述 <asp:DataListID="DataList1"runat="server"RepeatDirection="Horizontal"RepeatColumns="4"HorizontalAlign="Center"OnItemDataBound="DataList1_ItemDataBound"><ItemTemplate><divclass