468,107 Members | 1,503 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

AddHandler Causes Exception

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...
Nov 21 '05 #1
2 1480
"Raju Joseph" <vz******@msn.com> schrieb:
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?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2
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
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OZ**************@TK2MSFTNGP14.phx.gbl...
"Raju Joseph" <vz******@msn.com> schrieb:
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?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by SunshineGirl | last post: by
1 post views Thread by Luis Esteban Valencia Muñoz | last post: by
2 posts views Thread by Just Me | last post: by
6 posts views Thread by Carlo3030 | last post: by
5 posts views Thread by Slim | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.