Monday, January 18, 2010

VB.net raise events, calling other forms controls?

Hi, I am struggling to adapt to vb.net.


I need to know how to call another forms control from another form





e.g. if i was on form 2 and clicked a control, and I wanted to call cmdbtn1 on form1, what would I write, like in vb6 this was just 'call form1.cmdbtn1_click '


But every time I try anything like this it says: 'use raise events instead , not a member of windows.forms.form2'





I really need help on this so I would very much appreciate it, thanks.VB.net raise events, calling other forms controls?
You could put whatever you want to do in cmdbtn1_click in a class. Then you can access that function from both forms. If you need to access controls on the form then you can just pass the form to the function or create an overrideable function.





EG:





Public Function Overrides DoSomething(frm1 as form)


End Function





Or try





Raise Events form1.cmdbtn1_click





hth

No comments:

Post a Comment