vb.net: Why all contained controls within a groupbox do NOT respond to Enabling/disabling?
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 gbDa开发者_开发问答taEntry.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?
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:
When a container control has its enabled property set to false, all its contained controls are disabled, as well. For example, if the user clicks on any of the controls contained in a disabled GroupBox control, no events are raised.
(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.
精彩评论