Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:55:21+00:00 2026-06-12T18:55:21+00:00

I have a simple vb 2010 form that I want to be able to

  • 0

I have a simple vb 2010 form that I want to be able to set the enabled stated of all buttons on.
I have made similar functions for checkboxes and numericalUpDown controls that function as required, but for buttons the function does not seem to operate correctly.

Private Sub setButtonsState(ByVal state As Boolean)
    Dim cControl As Control
    For Each cControl In Me.Controls
        If (TypeOf cControl Is Button) Then
            cControl.Enabled = state
        End If
    Next cControl
End Sub

Which is called like so: setButtonsState(True)
This doesnt seem to have any effect at all with buttons, though buttonName.Enabled = True works OK…
Im pretty much what you’d call a noob at VB, so anyone help me out?
Ta

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:55:22+00:00Added an answer on June 12, 2026 at 6:55 pm

    Unless all of your buttons belong directly to the Form this is run in, then they won’t be accessed because this doesn’t cruise down through the control tree to get to them. A slightly different approach might be a more recursive method:

    Private Sub setButtonsState(ByVal controls as System.Windows.Forms.Control.ControlCollection, ByVal state as Boolean)
    
        For Each ctrl as Control in controls
            If (ctrl.HasChildren) Then setButtonsState(ctrl.Controls, state)
    
            If (TypeOf ctrl Is Button) Then ctrl.Enabled = state
        Next
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple search field on a form that is set as multiline
I have simple php validation form that is halfway working. If you leave the
I'm using Visual Basic 2010 Express. I have a form that can be minimized.
I have written a simple mysql search form that searches between two dates. This
Afternoon All, I have a simple file upload tutorial that i have completed for
I have been asked to build a rather simple form processor application that interacts
I have created a simple form that emails the entered values to a designated
I have a simple solution in Visual Studio 2010 containing a few static libraries,
I have a simple code using ctypes: Python 3.1.1 (r311:74480, Feb 23 2010, 11:06:41)
This is a simple website in ASP.NET with C# using VS 2010. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.