Quantcast
Viewing all articles
Browse latest Browse all 12583

Public event of another form

Hi,

I am using VS 2005

I have a toolbar in Main Mdi form with New and Edit Button and lot of forms

I have created Public Sub NewButton and Public Sub EditButton event in almost all forms

When I click on Mdi form's New button then it call Mdi Active Child NewButton event and when I click on Mdi form's Edit Button then it call Mdi Active Child's EditButton Event. It is working fine

But the problem is if any form has not EditButton Event or NewButton Event then it show exception that Public member... on form... not found.

I would like to know when I click new button then it will check whether active childform has newbutton event or not. if not then show message.

Please see my code:

    Private Sub btn_New_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_New.Click

        Dim Activefrm As Object
        Activefrm = Me.ActiveMdiChild
        Activefrm.NewButton

    End Sub

Then I edited it with the below:

    Private Sub btn_New_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_New.Click

        Dim Activefrm As Object
        Activefrm = Me.ActiveMdiChild

       If not Activefrm.nNewbutton is nothing then

        Activefrm.Newbutton

       End if
    End Sub

But it also not working and sending same exception:

Please help me. its urgent


Shakhawat


Viewing all articles
Browse latest Browse all 12583

Trending Articles