显示颜色对话框时,如何在颜色对话框中选择现有颜色 [英] How to select a existing color in color dialog box when color dialog box is shown

查看:100
本文介绍了显示颜色对话框时,如何在颜色对话框中选择现有颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将颜色设置为我的文本框。



如果我写一个事件来创建和访问颜色对话框我可以设置我想要的颜色。



但我的问题是,在打开颜色对话框时,默认选择的值应该是当前用于所选文本框的颜色。



如一般文本框背景颜色为白色。



当我写一个事件打开颜色对话框白色应该突出显示



怎么做

I want to set back color to my textbox.

If I write an event to create and access a color dialog box I can set the color which I want.

But my problem is that while opening the color dialog box the default selected value should be the color which is current used for the selected text box.

Such as generally textbox backcolor would be white.

When I write an event to open color dialog box white color should be highlighted

How to do this

推荐答案

我认为这解决了你的问题:



I think that solves your problem:

colorDlg.Color=txtAText.Backcolor;





见: ColorDialog [ ^ ]


我建​​议你设置这些ColorDialog属性:



AnyColor = true;

FullOpen = true;



然后,当你像这样使用ColorDialog时:
I suggest you set these ColorDialog Properties:

AnyColor = true;
FullOpen = true;

Then, when you use the ColorDialog like this:
private void btnOpenColorDialog_Click(object sender, EventArgs e)
{
    colorDialog1.Color = textBox1.BackColor;

    colorDialog1.ShowDialog();

    textBox1.BackColor = colorDialog1.Color;
}

如果TextBox的当前BackColor不是标准48纯色之一,则至少右侧显示的颜色选择器会显示当前TextBox BackColor。



要制作自定义颜色,您可以在为自定义颜色定义提供的16个插槽中定义 persist ,您需要做几件事:



0.从16个插槽中选择一个插槽用于自定义颜色。



1.移动十字线选择颜色



2.使用最右边的垂直滑块设置颜色强度



3.点击 in 那个垂直滑块



4.点击添加到自定义颜色按钮



5.点击确定

If the current BackColor of the TextBox is not one of the standard 48 solid colors, at least the color-picker displayed on the right will show you the current TextBox BackColor.

To make custom colors you define persist in the 16-slots provided for custom color definitions you need to do several things:

0. select a slot from the 16 slots for custom colors.

1. move the cross-hairs to select a color

2. set the color intensity using the vertical slider on the far right

3. click somewhere in that vertical slider

4. click the "Add to custom colors" button

5. click okay


这篇关于显示颜色对话框时,如何在颜色对话框中选择现有颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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