是否有可能在 winforms,vb.net中定义将出现在colordialog的自定义颜色框中的特定自定义颜色? 简而言之,是的. MSDN覆盖它 here.问题是它不是通过Color完成的 – 你需要处理BGR设置的值 – 即每
我的VB糟透了,但在C#中添加紫色:
using (ColorDialog dlg = new ColorDialog())
{
Color purple = Color.Purple;
int i = (purple.B << 16) | (purple.G << 8) | purple.R;
dlg.CustomColors = new[] { i };
dlg.ShowDialog();
}
反射器向我保证这类似于:
Using dlg As ColorDialog = New ColorDialog
Dim purple As Color = Color.Purple
Dim i As Integer = (((purple.B << &H10) Or (purple.G << 8)) Or purple.R)
dlg.CustomColors = New Integer() { i }
dlg.ShowDialog
End Using
