473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Traverse form buttons

Is there some easy programmable way of traversing all
button in a form and set their enabled state to false?

Something like

for each button x in this.form
x.enabled=false
end for

Thank you

PS Why doesn't this newsgroup email me anymore when I get
a response to my post?

Sebastian
Nov 20 '05 #1
3 1212
* "Sebastian Santacroce" <ss*********@ilogic.com> scripsit:
Is there some easy programmable way of traversing all
button in a form and set their enabled state to false?

Something like

for each button x in this.form
x.enabled=false
end for


<http://www.mvps.org/dotnet/dotnet/samples/controls/downloads/EnumerateControls.zip>

I never got a response by mail. Which newsreader do you use?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
e
Here's a way to do it...

Dim castControl As Windows.Forms.Control
Dim objButton As New Button

For Each castControl In yourFormHere.Controls
If castControl.GetType.Equals(objButton.GetType) Then
castControl.Enabled = False
End If
Next

Dunno about the emails thing.

"Sebastian Santacroce" <ss*********@ilogic.com> wrote in message
news:0c****************************@phx.gbl...
Is there some easy programmable way of traversing all
button in a form and set their enabled state to false?

Something like

for each button x in this.form
x.enabled=false
end for

Thank you

PS Why doesn't this newsgroup email me anymore when I get
a response to my post?

Sebastian

Nov 20 '05 #3
Hi Sebastian,

The following will do the trick for all Buttons on the Form and all those
contained within Panels and/or other Controls. It works by going through each
Control's collection of child Controls. You can start it with a Form (which is
a Control itself) or with any Control on the Form.

Call it using:
EnableAllButtons (Me, TrueOrFalse)

Sub EnableAllButtons (oControl As Control, EnabledState As Boolean)
Dim oChildControl As Control
For Each oChildControl in oControl.Controls
If TypeOf (oChildControl) Is Button Then
oChildControl.Enabled = EnabledState
End If
EnableAllButtons (oChildControl, EnabledState)
Next
End Sub

Naturally this can be adapted to do anything with all the Controls of any
particular type.

Regards,
Fergus
Nov 20 '05 #4

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

Similar topics

3
by: john | last post by:
I am using ASP.NET and I have a datagrid. One of the columns in my grid is all checkboxes. When the user clicks on a certain button on the page, which is not in the grid, I want to be able to...
5
by: ChrisR | last post by:
Hi all Ive have a Main Form with Command Buttons down the Left hand side, that open various forms. Clicking on a button opens a Sub Form which is moved to take up 3/4s of the right of the main...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
2
by: Aravind | last post by:
Hi folks. I have a form, frmHistory, which has 4 command buttons: Sort Title (cmdSortTitle), Sort Name (cmdSortName), Due Today (cmdDueToday), and Due List (cmdDueList). Sort Title and Sort...
2
by: j.mandala | last post by:
This had got to be something obvious that I am too blind to see! Funny problem: one of my users has my application linked to a SQL Server Backend. Front end it Access XP (SP3). The first form...
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
0
by: news.microsoft.com | last post by:
I'm learning asp.net I have few text boxes & radio buttons on my form. I was able to display the data by databinding. Now how do I change the records ? Is there currencymanager in asp.net...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
1
by: MichaelFord85 | last post by:
I have built an MS access with student information, such as SSN, Local address, city, state, grade, etc. The SSN is the primary key for the student table - there is a second table but that isn't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.