Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Call MDI form procedure in Toolbar

Call MDI form procedure in Toolbar

Scheduled Pinned Locked Moved Visual Basic
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LC Chan
    wrote on last edited by
    #1

    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:)

    C A 2 Replies Last reply
    0
    • L LC Chan

      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:)

      C Offline
      C Offline
      Charlie Williams
      wrote on last edited by
      #2

      Me.ActiveMdiChild returns an instance of type Form. You're getting the error because Form doesn't contain a method called add_Record. You need to cast the return value of Me.ActiveMdiChild to the type of the child form the contains that method.

      CType(Me.ActiveMdiChild, MyMdiChild).add_Record()

      Charlie if(!curlies){ return; }

      1 Reply Last reply
      0
      • L LC Chan

        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:)

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        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 this Select 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 it dim myform as new AdD_record() myform.show or if it is a procedure in a form myform.add_record() will do assuming myform is an open form.

        A 1 Reply Last reply
        0
        • A Anonymous

          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 this Select 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 it dim myform as new AdD_record() myform.show or if it is a procedure in a form myform.add_record() will do assuming myform is an open form.

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          This was a build error, so registered event handlers aren't the problem.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups