AddHandler Causes Exception

  • Thread starter Thread starter Raju Joseph
  • Start date Start date
R

Raju Joseph

Hi All,

I am trying to implement some common services for DataGrid control by
implementing IExtendee and providing users with some properties they can
set. I need to process some code in the DataGrid's Form Load event. So, I
wrote

If (Not (me.DesignMode)) Then
AddHandler DataGrid.FindForm().Load, AddressOf LoadHandler
End If

This is generating an exception at run time. I am not able to hook to the
Load event.

Any ideas or suggestions Please? I am trying to create something like a
Pluggin for all DataGrid controls in our project. Is there an easier way to
do this? I know I could have inherited the DataGrid control and wrote code
there, but didn't want to do sos This sounded more fun.

Thanks

Raju...
 
Raju Joseph said:
If (Not (me.DesignMode)) Then
AddHandler DataGrid.FindForm().Load, AddressOf LoadHandler
End If

This is generating an exception at run time. I am not able to hook to the
Load event.

What type of exception?
 
Sorry, I should have been more specific.

First my form does not even show up within the MDI form after executing the
line

If (Not (me.DesignMode)) Then
AddHandler DataGrid.FindForm().Load, AddressOf LoadHandler
End If

The form cannot be seen.

The exception happend when I close the MDI Form complaining about the
following code written in the Dispose method of my component.

If (Not (me.DesignMode)) Then
RemoveHandler DataGrid.FindForm().Load, AddressOf LoadHandler
End If

Hope this gives some insight. I am still trying to find out why this is
happening.

Thanks
 

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

Back
Top