Dear Frieds,
I have a problem, here it is....
When you want to lock controls in the window form, What is the coding for that?
Because, there I want to lock all controls in the window form when form is loading and only allow to view data through the window form. And then When you click on the Edit button or Add New button only that all the controls can be unlocked.
So, How do you lock text boxes?
AlanPosted Apr 29, 2008, 12:10 PM
To lock textboxes specifically, you can also set their ReadOnly properties to true either individually or in a loop as in Ryan's code:
foreach(Control c in this.Controls)
{
if (c is TextBox)
{
TextBox tb = (TextBox)c;
tb.ReadOnly = true;
}
}
Ryan AlfordPosted Apr 29, 2008, 10:04 AM
foreach(Control c in this.Controls)
{
c.Enabled = false;
}
then you will need to enable any buttons that you want enabled. then do the opposite when they click one of those enabled buttons.
Scott LyslePosted Apr 29, 2008, 9:58 AM