Call MDI form procedure in Toolbar
-
Hi All, I created a Toolbar in the Main form and it has some buttons like Add,Change,Delete. Let's say there are 2 child forms A & B. In each form, a public procedure - add_record() - is created. Now, I'd like to call the child form - add_record() in the button.click() event. But it seems the compiler didn't accept it. Here's the code in tool bar click event.
Protected Sub toolBar_Click(ByVal sender As Object,
ByVal e As oolBarButtonClickEventArgs)Select Case tblMain.Buttons.IndexOf(e.Button) Case 1 Call Me.ActiveMdiChild.add\_recod() /\* build error occur \*/ End Select
End Sub
I think i'm using a wrong approach with Toolbar. Would anyone give me some advice. Many thanks, Wilfred:)
-
Hi All, I created a Toolbar in the Main form and it has some buttons like Add,Change,Delete. Let's say there are 2 child forms A & B. In each form, a public procedure - add_record() - is created. Now, I'd like to call the child form - add_record() in the button.click() event. But it seems the compiler didn't accept it. Here's the code in tool bar click event.
Protected Sub toolBar_Click(ByVal sender As Object,
ByVal e As oolBarButtonClickEventArgs)Select Case tblMain.Buttons.IndexOf(e.Button) Case 1 Call Me.ActiveMdiChild.add\_recod() /\* build error occur \*/ End Select
End Sub
I think i'm using a wrong approach with Toolbar. Would anyone give me some advice. Many thanks, Wilfred:)
Me.ActiveMdiChild
returns an instance of typeForm
. You're getting the error becauseForm
doesn't contain a method calledadd_Record
. You need to cast the return value ofMe.ActiveMdiChild
to the type of the child form the contains that method.CType(Me.ActiveMdiChild, MyMdiChild).add_Record()
Charlie if(!curlies){ return; }
-
Hi All, I created a Toolbar in the Main form and it has some buttons like Add,Change,Delete. Let's say there are 2 child forms A & B. In each form, a public procedure - add_record() - is created. Now, I'd like to call the child form - add_record() in the button.click() event. But it seems the compiler didn't accept it. Here's the code in tool bar click event.
Protected Sub toolBar_Click(ByVal sender As Object,
ByVal e As oolBarButtonClickEventArgs)Select Case tblMain.Buttons.IndexOf(e.Button) Case 1 Call Me.ActiveMdiChild.add\_recod() /\* build error occur \*/ End Select
End Sub
I think i'm using a wrong approach with Toolbar. Would anyone give me some advice. Many thanks, Wilfred:)
I need to know the name of the object. did you manually type the procedure below because it lacks the
handles toolbar1.click
assuming the name of the toolbar is toolbar1. Protected Sub toolBar_Click(ByVal sender As Object, ByVal e As oolBarButtonclickEventArgs) HANDLES toolbar1.click find another method for thisSelect Case tblMain.Buttons.IndexOf(e.Button)
I'm in an internet cafe so ican't test any code Lastly if Add_record() is form, then you need to make an instance of itdim myform as new AdD_record() myform.show
or if it is a procedure in a formmyform.add_record()
will do assuming myform is an open form. -
I need to know the name of the object. did you manually type the procedure below because it lacks the
handles toolbar1.click
assuming the name of the toolbar is toolbar1. Protected Sub toolBar_Click(ByVal sender As Object, ByVal e As oolBarButtonclickEventArgs) HANDLES toolbar1.click find another method for thisSelect Case tblMain.Buttons.IndexOf(e.Button)
I'm in an internet cafe so ican't test any code Lastly if Add_record() is form, then you need to make an instance of itdim myform as new AdD_record() myform.show
or if it is a procedure in a formmyform.add_record()
will do assuming myform is an open form.