111,129
社区成员
发帖
与我相关
我的任务
分享
public static Color GetColor(string rgbHex)
{
if(string.IsNullOrEmpty(rgbHex))
return Color.Empty;
if(rgbHex.Length == 8)
return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0, 2), 16),
Convert.ToInt32(rgbHex.Substring(2, 2), 16),
Convert.ToInt32(rgbHex.Substring(4, 2), 16),
Convert.ToInt32(rgbHex.Substring(6, 2), 16));
return Color.FromArgb(Convert.ToInt32(rgbHex.Substring(0,2),16),
Convert.ToInt32(rgbHex.Substring(2,2),16),
Convert.ToInt32(rgbHex.Substring(4,2),16));
}
label1.MouseEnter += delegate
{
label1.Background = Brushes.Red;
};
label1.MouseLeave += delegate
{
label1.Background = Brushes.Blue;
};