tags:

views:

545

answers:

2

My problem is: When my application is opened, I disable all buttons (in form_Load) and their color changes to the color of the background. But then I do some action (like clicking on a button), and in this action I disable the buttons again.

Now some of these buttons become GRAY and others become as the background.

Why is this? I don't want the the gray effect. Normally when I disable the button at the beginning of the application, it becomes the color I expect, but when I try to disable them again this strange behavior appeared. What to do?

My code is like:

private void _btnDownload2PC_Click(object sender, EventArgs e)
{
    // do action 
    _btnDownloadToPC.Enabled=false; // its color became gray
    _btnDownloadToPhone.Enabled=false; // its color became like the 
                                       // background color and it can't 
                                       // be pressed 
}

I figured out that the problem is when I use the button_MouseLeave() or button_MouseMove() functions. For example:

private void _btnOneToCort_MouseLeave(object sender, EventArgs e)
{
    this._btnOneToCart.Image=global::MyProject.Properties.Resources.button3over;
}

but this doesn't make sense. Why does this function change my button settings (I don't know what these are) When I use these function this strange behavior appears, but when I don't, everything goes right?

A: 

Why don't disable buttons in designer? If not acceptable, do that in form constructor not Form_Load.

Also, how can you click on button if it's disabled?

Are form color settings default? Have you changed windows theme color preferences?

abatishchev
i click on the button when its enabled after a certain action but when i disable it again this behavior happened.also my problem is not when i open the application only but also when i try to use and button (to click on it) and then try to disbale it.what is the windows theme color preferences?
Eng.Basma
windows theme color preferences - that is settings in Right click on Desktop - color of menus, controls, etc. That is what Henk is talking. This settings changes default colors into SystemColors.Controls, etc. Check that
abatishchev
what about System.Drawing.Color.Transparent .. i tried SystemColor.Color but still when i click on the button its color became gray not the background color.
Eng.Basma
A: 

You can programmatically access the color of a button. Set a breakpoint and do that to see if they really are changing.

My guess: the image that you are setting has a gray background that is different than the standard disabled color. You will need to edit the image and remove the background.

colithium