变量值不变...... [英] Variable value not changing...

查看:91
本文介绍了变量值不变......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一款非常简单的应用。 实际上,我还在处理GUI,所以事情上并没有很多其他代码。 但是,出于某种原因,即使我把<一个直接的赋值设置为true - 没有案例逻辑,没有if - 只是直接的
赋值为true - 值不会改变。 检查图像输出。


我设置一个断点并将值放在监视列表上。 如你所见,我设置为可见,它永远不会改变。 下一行的开头仍然在观察列表中显示为false。 就像我说的那样,到目前为止只有三个函数
,这些函数都没有改变相关的面板。


如果我在监视列表中编辑变量的值,那么立即恢复直接回到假! 为什么这个值不能改变?!


有趣的是,如果我在此之前改变另一个小组,那么作业就完美了。 为什么这不起作用? 这是一个简单的代码。







$

解决方案

控件可见(只有父母和祖先也可见时,
可见才会返回 true )。可能这在文档中有描述,但也可以在源代码中看到:

https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Control.cs ,34eb26e129516529


在您的情况下,
panelApprovals 的父级可能是不可见的。
< /跨度>


This is a very simple app.  Actually, I'm still just working on the GUI, so there really isn't a lot of other code in the thing.  However, for some reason, even when I put <a straight assignment to true - no case logic, no if's - just a straight assignment to true - the value doesn't change.  Check the image for the output.

I set a breakpoint and put the value on the watch list.  As you can see, I set to visible and it never changes.  The beginning of the next line still shows it as false in the watch list.  Like I said, there are only like three functions here so far, none of which alter the panel in question.

If I edit the variable's value in the watch list, it immediately reverts straight back to false!  Why can this value not be changed?!

Interestingly, the assignment works perfectly if I alter another panel before this one.  Why is this not working?  It's simple code.

解决方案

A control is visible (and Visible returns true) only if the parent and ancestors are visible too. Probably this is described in documentation, but can be also observed in the sources: https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Control.cs,34eb26e129516529

In your case, perhaps the parent of panelApprovals is invisible.


这篇关于变量值不变......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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