How to cast the arguments in the MdiChildActivate event?

  • Thread starter Thread starter Ronny Van Assche
  • Start date Start date
R

Ronny Van Assche

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 MdiChildActivate 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.Windows.Forms.Form)e).GetHashCode() it gives me a compile error
"Cannot convert type 'System.EventArgs' to 'System.Windows.Forms.Form".

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

Kind regards,

Ronny
 
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.
 
Thanks Nicholas


Nicholas Paldino said:
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]
- (e-mail address removed)

Ronny Van Assche said:
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 MdiChildActivate 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.Windows.Forms.Form)e).GetHashCode() it gives me a compile error
"Cannot convert type 'System.EventArgs' to 'System.Windows.Forms.Form".

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

Kind regards,

Ronny
 
Back
Top