I am new in Windows Forms Applocation. I am using Visual Studio 2010 with .NET framework 4.0. In my project, I used a Panel to place controls such as TextBox, DatePicker, CheckBox, ComboBox and Button. Here I want to disable only SPECIFIC CONTROLS when I make that panel Visible. How would I achieve this?? I searched a lot on google but it doesn't give me some relevant results.
Disable specific controls placed on panel
414 views Asked by Rahul More At
3
There are 3 answers
0
On
bool canEdit = false
private void panel1_VisibleChanged(object sender, EventArgs e)
{
button1.Enabled = false
checkbox1.Enabled = false
//...
}
and you can define a bool variable to check what to do.like below:
bool canEdit = false;
private void panel1_VisibleChanged(object sender, EventArgs e)
{
if (!canEdit)
{
button1.Enabled = false;
//and other components that u want
}
else
{
button1.Enabled = true;
//and other components that u want
}
}
You can do something like that:
You can apply switch case on control type within foreach loop as well, to know whether the control is TextBox, DatePicker etc.