How to cast the arguments in the MdiChildActivate event?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ronny Van Assche

    How to cast the arguments in the MdiChildActivate event?

    Hi,

    I am working with an Mdiform and several Childforms who are loaded
    dynamically with reflection.
    Every time a child is getting activate i must reinitialize the menu.
    (i think) This is something to handle in the MdiChildActivat e event of the
    MdiForm.

    My problem now is to get the initial properties of the active child.
    When i try to cast the "e" arguments to
    ((System.Window s.Forms.Form)e) .GetHashCode() it gives me a compile error
    "Cannot convert type 'System.EventAr gs' to 'System.Windows .Forms.Form".

    Now the question. What is the correct cast for this?

    Kind regards,

    Ronny


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: How to cast the arguments in the MdiChildActivat e event?

    Ronny,

    The EventArgs instance that was passed in doesn't have any information
    about the child being activated. Also, it is of type EventArgs, which can
    not be cast to a type of System.Windows. Forms.Form. You will have to get
    the active mdi child using the MDI parent form's ActiveMdiChild property.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Ronny Van Assche" <vanasro@hotmai l.com> wrote in message
    news:OicT3o8kDH A.2512@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi,
    >
    > I am working with an Mdiform and several Childforms who are loaded
    > dynamically with reflection.
    > Every time a child is getting activate i must reinitialize the menu.
    > (i think) This is something to handle in the MdiChildActivat e event of the
    > MdiForm.
    >
    > My problem now is to get the initial properties of the active child.
    > When i try to cast the "e" arguments to
    > ((System.Window s.Forms.Form)e) .GetHashCode() it gives me a compile error
    > "Cannot convert type 'System.EventAr gs' to 'System.Windows .Forms.Form".
    >
    > Now the question. What is the correct cast for this?
    >
    > Kind regards,
    >
    > Ronny
    >
    >[/color]


    Comment

    • Ronny Van Assche

      #3
      Re: How to cast the arguments in the MdiChildActivat e event?

      Thanks Nicholas


      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:uYULJX%23k DHA.2500@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > Ronny,
      >
      > The EventArgs instance that was passed in doesn't have any information
      > about the child being activated. Also, it is of type EventArgs, which can
      > not be cast to a type of System.Windows. Forms.Form. You will have to get
      > the active mdi child using the MDI parent form's ActiveMdiChild property.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > "Ronny Van Assche" <vanasro@hotmai l.com> wrote in message
      > news:OicT3o8kDH A.2512@TK2MSFTN GP09.phx.gbl...[color=green]
      > > Hi,
      > >
      > > I am working with an Mdiform and several Childforms who are loaded
      > > dynamically with reflection.
      > > Every time a child is getting activate i must reinitialize the menu.
      > > (i think) This is something to handle in the MdiChildActivat e event of[/color][/color]
      the[color=blue][color=green]
      > > MdiForm.
      > >
      > > My problem now is to get the initial properties of the active child.
      > > When i try to cast the "e" arguments to
      > > ((System.Window s.Forms.Form)e) .GetHashCode() it gives me a compile error
      > > "Cannot convert type 'System.EventAr gs' to 'System.Windows .Forms.Form".
      > >
      > > Now the question. What is the correct cast for this?
      > >
      > > Kind regards,
      > >
      > > Ronny
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...