Click here to Skip to main content
15,910,009 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to activate a button in other form (using code)?
Posted
Updated 17-Oct-10 23:27pm
v2
Comments
Sandeep Mewara 18-Oct-10 6:31am    
Why posting same question multiple times...
[no name] 18-Oct-10 6:32am    
this time is slightly different! :D

Or, cleaner than Answer 1:
OtherFormCodeBehindName.ButtonName.PerformClick();

and make the Button public or internal as needed.
 
Share this answer
 
Comments
[no name] 18-Oct-10 6:32am    
can you capture the eventargs this way?
Toli Cuturicu 18-Oct-10 8:19am    
Of course not! I don't need them, since for Button.Click it's always EventArgs.Empty. Always! So, you would better correct your flawed vote.
OtherFormCodeBehindName.ButtonName_Click(null, null);


make the button on 'OtherForm's click method Public
 
Share this answer
 
v3
Comments
E.F. Nijboer 18-Oct-10 5:34am    
Good answer!
Dalek Dave 18-Oct-10 5:38am    
Good Answer.
[no name] 18-Oct-10 5:43am    
second time i answered this q!!
thx anyway
Actually its not the right kind of thing to do to activate some button from other form!

try to use classes by creating a class which will perform the required operation that you want.

any way you can use this way-

dim of as new OtherForm
of.YourButton.content="Hello!"
 
Share this answer
 
Comments
[no name] 18-Oct-10 7:58am    
OtherForm of = new Form();
of.Yourbutton.content = "Hello!";

C# version of above as this is tagged c#
Tarun.K.S 18-Oct-10 8:00am    
oops!! sorry and thanks JFergulbops!

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