We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Disabling Buttons

So I have a main form and 5 other forms. When I press a button on the main form, I want it to open Form2 and disable a certain button in form2 so that it cannot be used. I produced this code but the button is still active and there is no effect. Please help.

 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        My.Forms.Form2.SaveVISACaseButton.Enabled = False
        My.Forms.Form2.SaveVISACaseButton.Visible = False
        Dim form2 As New Form2
        My.Forms.Form2.SaveVISACaseButton.Enabled = False
        My.Forms.Form2.SaveVISACaseButton.Visible = False
        form2.Show()
        Me.Hide()

    End Sub
3
Contributors
2
Replies
18 Hours
Discussion Span
6 Months Ago
Last Updated
6
Views
albert.staszak
Newbie Poster
1 post since Nov 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

It appears to me that if Form2 is already designed that you won't need to Dim a new one just show the one you have.

tinstaafl
Nearly a Posting Virtuoso
1,336 posts since Jun 2010
Reputation Points: 360
Solved Threads: 235
Skill Endorsements: 14

Declare object instance of form2 and use it to disable or visble a button in form2.
You already declare it but you didn't use it.
Try this :

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim form2 As New Form2
    form2.SaveVISACaseButton.Enabled = False
    form2.SaveVISACaseButton.Visible = False
    form2.Show()
    Me.Hide()
End Sub
Jx_Man
Senior Poster
3,538 posts since Nov 2007
Reputation Points: 1,488
Solved Threads: 524
Skill Endorsements: 64

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0653 seconds using 2.7MB