Click here to Skip to main content
15,886,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
how to change the label after clicking button from another form?
In the form 1, i disabled a buttonA, the buttonA only enable when i clicking the buttonB from another form

2 forms are opening together




The below is my coding, but it is not working, hope someone can help me, thanks a lot

What I have tried:

-------this form1
<pre>Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Button1.Enabled = False

-------this is another form
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Form2.Button1.Enabled = True
Posted
Updated 28-Jul-20 19:39pm
v2

It happens because you disable the Button inside the Form2_Load-method. This method is called when the Form is activated.
Why don't you disable the Button1 of Form2 with the Designer (or the Designer-Script) ?
 
Share this answer
 
Comments
kang jeq Gan 29-Jul-20 1:33am    
i changed to disable with designer, but still not working :(
Ralf Meier 29-Jul-20 2:55am    
And you have deleted the Code-line inside the Form_Load-method ?
But I'm also a little confused with your descriptions ... which Button from which Form should enable which Button on which Form. I suggest you use unique descriptions.
Basicly your code must work if it's called - but it is possible that another method compromise it ...
Private Sub ButtonB_Click(sender As Object, e As EventArgs) Handles ButtonB.Click
Form1.ButtonA.Enabled = True
end sub
 
Share this answer
 
Comments
kang jeq Gan 29-Jul-20 1:44am    
cannot, now the problem is like the form2 not refresh (button still cannot press) after I press the button from another form
kgmmurugesh 29-Jul-20 2:28am    
Enable that button

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900