电阻颜色代码 [英] Resistor color code

查看:190
本文介绍了电阻颜色代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C#制作了将电阻值转换为颜色代码的应用程序.

I made app in C# that convert resistor value to color codes.

如何显示颜色而不是文本.例如,如果我输入15K,它将显示棕色,绿色和橙色,而不是文本.

https://postimg.org/image/4tccjjnax/

https://postimg.org/image/4tccjjnax/

当我设置label15.BackColor = colours(res [0]-'0')
我收到错误消息,无法将类型字符串隐式转换为System.Drawing.Color
When I set label15.BackColor=colours(res[0] - '0')
I get error cannot implicitly convert type string to System.Drawing.Color

推荐答案

您可以使用Color.FromName方法转换名称颜色,只要您的颜色名称与System.Drawing.Color中的成员名称匹配即可.

You can use the Color.FromName method to convert the name to a color, so long as your color names match the member names in System.Drawing.Color.

示例:

string name = "Brown";

颜色c = Color.FromName(name); label1.BackColor = c;

Color c = Color.FromName(name); label1.BackColor = c;


这篇关于电阻颜色代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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