3 Replies - 249 Views - Last Post: 25 April 2019 - 03:01 AM Rate Topic: -----

#1 M3t3xu   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 18

How to change values of specific buttons in form?

Posted 25 April 2019 - 01:22 AM

Hello everyone!

I'm trying to change text and enabled value of buttons that text is "SELECTED".
I have this code:
    Public Sub ReloadButtons()
        For Each b In Me.Controls.OfType(Of Button)
            If b.Text = "SELECTED" Then
                b.Enabled = True
                b.Text = "SELECT"
            End If
        Next
    End Sub



But when I run it buttons stay the same.
What am I doing wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: How to change values of specific buttons in form?

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6796
  • View blog
  • Posts: 28,083
  • Joined: 12-December 12

Re: How to change values of specific buttons in form?

Posted 25 April 2019 - 01:39 AM

That code works for me, with a simple sample form and a few buttons.

Are you sure the code executes at all, put a breakpoint in it or pop up a MessageBox.
Are the buttons hidden as children of another control (or a different form)?
Is "SELECTED" in capitals and doesn't contain extra characters such as spaces?
Was This Post Helpful? 1
  • +
  • -

#3 M3t3xu   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 18

Re: How to change values of specific buttons in form?

Posted 25 April 2019 - 01:46 AM

Thanks for your reply. Yes, they are children of splitcontainer.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6796
  • View blog
  • Posts: 28,083
  • Joined: 12-December 12

Re: How to change values of specific buttons in form?

Posted 25 April 2019 - 03:01 AM

So you probably need something like Me.splitContainerReference.Controls...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1