|
-
Jan 24th, 2011, 03:18 PM
#1
Thread Starter
Hyperactive Member
Accessibg the controls of a form
Lately I am having a problem accessing the controls of a form . I was used to use the following code back in VB6 :
For Each GenericControl In Me.Controls
If TypeOf GenericControl Is System.Windows.Forms.Button And Mid(GenericControl.Name, 14, 11) = "COEFICIENT_" Then
GenericControl.Visible = False
End If
Next GenericControl
in which GenericControl has been defined in a Module as :
Public GenericControl As Object
However I found out that the above code , now in .NET , misses some controls . For example if the buttons I am looking for are located in a group box , then the above code won't catch them . I used the following code :
For Each GenericControl In Me.GroupBox1
and it worked fine , but the problem is that on the form there are plenty of group boxes . Moreover , the same thing happens in many forms , therefore I wonder if there is any possibility to catch all the controls on a form , no matter if they are within a group box or not .
In case there isn't , then is it possible to reduce the lines of code by making a search within all group boxes of the form ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|