How to cast the arguments in the MdiChildActivate event?

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
R

Ronny Van Assche

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top