how do i change the checkbox color to dark grey (disable like) in c#?
i made custom checkbox tree and i wa开发者_Go百科nt the first check box to be in Dark grey color instead of white (the check box itself not his text..)
*. the custom checkbox tree is several checkboxes that order in different places in the form..
how can i do it ?
I don't think there is a direct way to do so. However, you can make your own CheckBox using a Button and a Label.
Change button background image or color on events like "button1_Click".
Inside the event you can make a flag that says if its checked or not checked, and change it with every click event. When the flag is "true" the background image will be image with "V" and when its "false" it will be changed to an image without "V".
Instead of calling checkBox1.Checked you can check if the flag is true or false.
(source: katzer at www.uni-graz.at)
if you need help with making the 2 images, you can e-mail me and I will do it.
The Code can be like this:
//"checked" and "notChecked" are the images names.
private void button1_Click(object sender, EventArgs e)
{
if(checkedFlag == true)
{
button1.BackgroundImage = Properties.Resources.notchecked;
checkedFlag = false;
}
else
{
button1.BackgroundImage = Properties.Resources.checked;
checkedFlag = true;
}
}
You only need to make the flag start value as false and make the image centered or stretched.
精彩评论