将按钮背景颜色转换为C#winform中的颜色代码 [英] Convert button background color to color code in C# winform

查看:339
本文介绍了将按钮背景颜色转换为C#winform中的颜色代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个。

我有两个按钮button1背景颜色为红色,button2背景颜色为蓝色现在我想将按钮背面颜色转换为颜色代码并在textbox1中显示颜色代码然后我保存在SQl数据库的textbox1中显示的代码。

当我将颜色代码保存在数据库中时,我使用此颜色代码来更改显示的其他按钮的运行时的背景颜色以其他形式



等待你的帮助

我正在使用C sharp winform应用程序



我尝试了什么:



i不知道我该怎么做

hi every one .
I have two button button1 background color is red and button2 background color is Blue now i want to convert the button back color to color code and display the color code in textbox1 and then i save the code that display in textbox1 in SQl database .
When once i save the color code in database then i use this color code to change the background color on run time of other buttons that are show in some other form

Waiting your help
i'm working on C sharp winform application

What I have tried:

i have no idea how can i do this

推荐答案

如果您使用 Color.ToArgb方法(System.Drawing)| Microsoft Docs [ ^ ]它将返回一个表示该颜色的整数值(ARGB位代表Alpha / Red / Green / Blue并指定一个绝对8位的颜色像素颜色系统)

您可以以任何方式存储整数,稍后使用FromArgb方法将其作为颜色值返回。
If you use the Color.ToArgb Method (System.Drawing) | Microsoft Docs[^] it will return an integer value representing that colour (The "ARGB" bit stands for Alpha/Red/Green/Blue and specifies a colour absolutely in a 8-bits-per-pixel colour system)
You can store the integer in any way you want, and later use the FromArgb method to return it as a Color value.


这篇关于将按钮背景颜色转换为C#winform中的颜色代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆