how to call an event inside another event

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 132
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

how to call an event inside another event

 
0
  #1
Jul 17th, 2009
i want to call the load event of the form inside the click event of the commant button depending upon certain condition
how can i do this?
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 186
Reputation: jbisono is an unknown quantity at this point 
Solved Threads: 24
jbisono's Avatar
jbisono jbisono is offline Offline
Junior Poster

Re: how to call an event inside another event

 
1
  #2
Jul 17th, 2009
Lets say that in the loadmain you set text for a label like this
Label1.Text = "Load Main"
But you want to do the same thing if you click a button, then create a function called for example
  1. private void SetLabel()
  2. {
  3. Label1.Text = "Load Main"
  4. }
then your load main will have this
  1. private void LoadMain()
  2. {
  3. SetLabel()
  4. }
and the button event
  1. private void buttonevent()
  2. {
  3. SetLabel()
  4. }

I hope you understand the idea. regards
If your already resolved your issue, flag it as solved.
José Bisonó
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 132
Reputation: babbu has a little shameless behaviour in the past 
Solved Threads: 13
babbu babbu is offline Offline
Junior Poster

Re: how to call an event inside another event

 
0
  #3
Jul 17th, 2009
thnx
so basically u cannot call the event as such
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 324
Reputation: sonia sardana has a little shameless behaviour in the past 
Solved Threads: 7
sonia sardana sonia sardana is offline Offline
Posting Whiz

Re: how to call an event inside another event

 
0
  #4
Jul 19th, 2009
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. Try
  3. MsgBox("Form Load")
  4. Catch ex As Exception
  5. MsgBox(ex.Message)
  6. End Try
  7. End Sub
  8.  
  9. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  10. Try
  11. Call Form1_Load(sender, e)
  12. Catch ex As Exception
  13. MsgBox(ex.Message)
  14. End Try
  15.  
  16. End Sub

But i suggest u to write the form load code into procedure,& call that procedure on form load & on button click,instead of calling form load event again
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC