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?

Recommended Answers

All 4 Replies

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

thnx
so basically u cannot call the event as such

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

hi all
button_Click(sender, e)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.