473,467 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Questions about User Controls

I've built a user control inherited button and I need it to change the
enabled property of all the controls on the form except for the labels and
buttons. I'd like to use this control on other forms to do the same.

I've tried the following:

Dim a as ControlsCollection = Me.Parent.Controls
Dim s as Controls

For Each s in a
s.enabled = False
Next

This sets all the controls enabled property to false including labels and
buttons. Any suggestions on how I can only change the enabled property of
certain controls?
--
TC
Sep 17 '05 #1
3 1227
Hi Terrance,

What do you mean by certain controls?
You can certainly check for certain control types and disable only those

[C#]
foreach(Control c in a)
{
if(a is Button || a is TextBox)
c.Enabled = false;
}
On Sat, 17 Sep 2005 05:15:01 +0200, Terrance <Te******@discussions.microsoft.com> wrote:
I've built a user control inherited button and I need it to change the
enabled property of all the controls on the form except for the labels and
buttons. I'd like to use this control on other forms to do the same.

I've tried the following:

Dim a as ControlsCollection = Me.Parent.Controls
Dim s as Controls

For Each s in a
s.enabled = False
Next

This sets all the controls enabled property to false including labels and
buttons. Any suggestions on how I can only change the enabled property of
certain controls?


--
Happy coding!
Morten Wennevik [C# MVP]
Sep 17 '05 #2
By certain controls I mean controls such as labels adn buttons.
--
TC
"Morten Wennevik" wrote:
Hi Terrance,

What do you mean by certain controls?
You can certainly check for certain control types and disable only those

[C#]
foreach(Control c in a)
{
if(a is Button || a is TextBox)
c.Enabled = false;
}
On Sat, 17 Sep 2005 05:15:01 +0200, Terrance <Te******@discussions.microsoft.com> wrote:
I've built a user control inherited button and I need it to change the
enabled property of all the controls on the form except for the labels and
buttons. I'd like to use this control on other forms to do the same.

I've tried the following:

Dim a as ControlsCollection = Me.Parent.Controls
Dim s as Controls

For Each s in a
s.enabled = False
Next

This sets all the controls enabled property to false including labels and
buttons. Any suggestions on how I can only change the enabled property of
certain controls?


--
Happy coding!
Morten Wennevik [C# MVP]

Sep 17 '05 #3
Well, if you need to disable only certain labels and certain buttons and not all labels and buttons, then you need some way of marking which controls should be disabled(for instance using the Tag or Name properties), or keep a separate list of those controls.

On Sat, 17 Sep 2005 16:44:04 +0200, Terrance <Te******@discussions.microsoft.com> wrote:
By certain controls I mean controls such as labels adn buttons.


--
Happy coding!
Morten Wennevik [C# MVP]
Sep 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the...
2
by: Wee Bubba | last post by:
i started by designing my web page using frames. i had my data entry form in an upper form and my data rows displaying in a lower frame. i soon discovered that ASP.NET is not really meant for...
23
by: Rick | last post by:
Hi, I'm currently preparing for an interview on VB.Net Development.. could someone please give me an idea as to what type of questions can one ask (it's a practical test) and what sort of things...
3
by: Terrance | last post by:
I've built a user control inherited button and I need it to change the enabled property of all the controls on the form except for the labels and buttons. I'd like to use this control on other...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
0
by: Michael.Suarez | last post by:
So we develop and maintain several applications used by several people in the same company, on the same intranet. There are several applications written in VB6, but going forward all of the new...
13
by: M.Siler | last post by:
Let me clarify from my last post. I am not using these 4 questions as the sole screening method. Currently in, the Tampa Bay area (Florida) there is an extreme shortage of C# developers. We have...
3
by: Chris S | last post by:
We are moving from ASP.Net 1.1 to ASP.Net 2.0. As we do not have the luxury of spending weeks trying out different techniques, I'd like to rely on some tried and true methods, but need some...
4
by: shamirza | last post by:
4 9 6 18.ATLAS-AJAX Note: - As an IT professional it's useful to know what the difference is between Hype and usefulness. For instance if there is a new technology coming in many programmers...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.