By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

AddHandler Causes Exception

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"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

P: n/a
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.