Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Method to enable all controls on a form
Message
 
To
06/07/2008 09:40:44
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01329162
Message ID:
01329289
Views:
13
Bonnie,

That's exactly what I was trying to do. I wanted to reference the parent container of the button, whether it was on the form or on a tab page. I hadn't thought about a panel being a separate container. I'll have to take that into account. Thanks for your help.

Linda

>Linda, you'll also need to add some code in there for container controls, such as Panels and UserControls ... IOW, if you have TextBoxes, CheckBoxes and/or ComboBoxes in a container control on your form, then you'll also have to go through the Controls collection of that Panel or UserControl, or whatever the container control is.
>
>~~Bonnie
>
>
>
>>UPDATE: I got this one with some help from a friend. I had to modify the code in the button click to reference the parent object as
>>((mmButton)sender).Parent. Now all is well.
>>
>>I want to have all the controls on a form disabled at start up. When the user hits the EDIT button, I want to enable all the TextBoxes, CheckBoxes and ComboBoxes. I created a small test form to try to figure this out but I'm not having any luck so far. I can't seem to hit the correct parent property. Any suggestions? Thanks.
>>Here's what I have.
>>
>>        private void btnEdit_Click(object sender, EventArgs e)
>>        {
>>            this.Ready4EditMode(this.ParentForm, "Edit");
>>        }
>>
>>        private void Ready4EditMode(Control currParent, string editMode)
>>        {
>>            foreach (Control ctl in currParent.Controls)
>>            {
>>                if (ctl is OakLeaf.MM.Main.Windows.Forms.mmTextBox ||
>>                        ctl is OakLeaf.MM.Main.Windows.Forms.mmCheckBox ||
>>                        ctl is OakLeaf.MM.Main.Windows.Forms.mmComboBox)
>>                {
>>                    if (editMode == "Edit")
>>                        ctl.Enabled = true;
>>                    else
>>                        ctl.Enabled = false;
>>                }
>>            }
>>        }
>>
Linda Harmes
HiBit Technologies, Inc.
Previous
Reply
Map
View

Click here to load this message in the networking platform