vb.net:为什么组框中包含的所有控件都不响应启用/禁用?
我正在开发一个 winform,其中包含多个控件,如文本框、单选按钮、datagridviews...所有这些控件都已添加到名为 gbDataEntry 的主组框中。
我的问题是当用户看到表单时,我设置 gbDataEntry.Enabled = False 但我想启用一些控件,例如 DataGridviews,以便用户可以滚动它们。禁用 gbDataGridview 后,我设置 DataGridView1.Enabled = True 但似乎 datagridview 不响应此行。为什么?
有什么问题吗?
I'm working on a winform which contains several controls like textboxes, radio buttons, datagridviews... All of these controls have been added to a main group box called gbDataEntry.
My problem is when the user is seeing the form, I set gbDataEntry.Enabled = False but I want to enable some controls like DataGridviews so the user can scroll them. After disabling gbDataGridview I set DataGridView1.Enabled = True but it seems that the datagridview does not respond to this line. Why?
Is anything wrong with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是标准的 .NET 行为(如评论中所述):如果禁用容器,则它包含的所有控件都将被禁用,并且无法单独启用:
(来自 MSDN 上的 Control.Enabled 属性)
为什么要这样实现呢?对此的混乱解决方案是单独启用/禁用控件。
This is standard .NET behaviour (as mentioned in the comment): if a container is disabled then all controls it contains are disabled and cannot be enabled separrately:
(from Control.Enabled Property on MSDN)
Why do you want to implement this in such a way? The messy solution to this is to enable/disable controls individually.