I have a TableLayoutPanel
with a number of TextBoxes
and GroupBoxes
. I have set this TableLayoutPanel.Enabled = false
.This Disables all the TextBoxes
and Groupboxes
and the Scrollbar
. Is their anyway i can enable
the scrollbar
even if the TableLayouPanel.Enabled = false
?
To achieve this automatically, you can subscribe to the EnabledChanged
event of your TableLayoutPanel
. You can subscribe to the event using the designer, or with the following line of code:
tableLayoutPanel.EnabledChanged += tableLayoutPanel_EnabledChanged;
Then, from the event handler, we can simply set the enabled property of the scroll bar to match the enabled property value of the TableLayoutPanel:
private void tableLayoutPanel_EnabledChanged(object sender, EventArgs e)
{
scrollbar.Enabled = tableLayoutPanel.Enabled;
}
Now, whenever the enabled state of the TableLayoutPanel changes, the scroll bar enabled state will be updated to match.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.