954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to call an event inside another event

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?

babbu
Posting Whiz in Training
208 posts since Jun 2009
Reputation Points: -1
Solved Threads: 23
 

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

private void SetLabel()
{
Label1.Text = "Load Main"
}

then your load main will have this

private void LoadMain()
{
SetLabel()
}

and the button event

private void buttonevent()
{
SetLabel()
}


I hope you understand the idea. regards

jbisono
Posting Pro in Training
442 posts since May 2009
Reputation Points: 71
Solved Threads: 59
 

thnx
so basically u cannot call the event as such

babbu
Posting Whiz in Training
208 posts since Jun 2009
Reputation Points: -1
Solved Threads: 23
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            MsgBox("Form Load")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Call Form1_Load(sender, e)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    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

sonia sardana
Posting Whiz
326 posts since Mar 2008
Reputation Points: 0
Solved Threads: 8
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You