开发者

.NET Form Ignores button.Enabled flag

开发者 https://www.devze.com 2023-03-11 00:41 出处:网络
I am trying to set a button to the Enabled state when certain conditions are met, but it doesn\'t seem to pay attention to when I set it to true. When I debug through the code, and put a watch on the

I am trying to set a button to the Enabled state when certain conditions are met, but it doesn't seem to pay attention to when I set it to true. When I debug through the code, and put a watch on the Enabled variable, it changes to true, but when I mouseover the variable after it is set to true, it still says it is false. The button remains disabled when it needs to be enabled. Has anyone else ever run into this?

Here is the code I am having issues with:

if (!thisCondition){
     this.btnOK.Enabled = true;
}
开发者_如何学Go

There's really not much more to it... it seems silly I know.


If you have a control that you enable, but it is within a disabled parent control, it will remain disabled.


Do you have any mouseevent? Are you in a for or while condition? The else condition, is it present?


I found the issue, there was a function that the debugger was stepping over that I failed to notice that was setting the value back arbitrarily. Gotta love unreadable code!

0

精彩评论

暂无评论...
验证码 换一张
取 消