Re: General Event Handler
From: One Handed Man \( OHM - Terry Burns \) ("One)
Date: 11/05/04
- Next message: Lloyd Dupont: "string as lock key?"
- Previous message: Paul Rudin: "Re: ArrayList adapter problem"
- In reply to: Guy Gani: "Re: General Event Handler"
- Next in thread: Paul: "Re: General Event Handler"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 5 Nov 2004 09:21:27 -0000
This on its own does not give me enough information. As you say this compiles ok, but I dont know how you are calling the show control and what you have on the form.
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Guy Gani" <ganiguy@netvision.net.il> wrote in message news:%238QqjZxwEHA.3612@tk2msftngp13.phx.gbl...
This is a nice workaround that I haven't tought about, however I would like to handle on the form the user control events raised by RaiseEvent and deal with exceptions in the regular exception handler.
Please take a look at my code and see why it breaks, if this piece of code is fixed, it should work fine.
Thanks
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%23$oMsUxwEHA.384@tk2msftngp13.phx.gbl...
You could start your application from a Sub Main, and have a Try / Catch Block around the form
Try
Dim mf as new Form1
mf.ShowDialog()
Catch GeneralException as Exception
'
End Try
--
OHM ( Terry Burns ) * Use the following to email me *
Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Guy Gani" <ganiguy@netvision.net.il> wrote in message news:%234wMC5wwEHA.3528@tk2msftngp13.phx.gbl...
Hello,
I have a small application with one form and a user control on it. The user control is loaded during runtime and can be changed when the user selects the appropriate one from a tree, something like microsoft .msc files.
I would like to have one function on the form that handles all the user events that raised from the various user controls. The problem is that that user controls are different and raised different events and I couldn't figure out how to do that. (it is possible in VB6 by declaring the user control with VBControlExtender and handle all events using ObjectEvent procedure on the form).
I used the following code whenever creating the usercontrol at runtime on the form:
Private ctl_Module As Windows.Forms.UserControl 'Embedded user control object
Private Sub ShowControl(ByRef pCtrl As Windows.Forms.UserControl)
Dim Idx As Integer
Dim eh As System.Delegate
eh = New EventHandler(AddressOf myGeneralEventHandler)
Dim events_info As System.Reflection.EventInfo() = ctl_Module.GetType.GetEvents()
For Idx = 0 To events_info.Length - 1
If events_info(Idx).Name = "LogStatus" Then 'Test to exclude user control events
events_info(Idx).AddEventHandler(pCtrl, eh) '<-- This is where the error occured
End If
Next
End Sub
This piece of code compiles fine, however when I run it I got the following error message:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Object type cannot be converted to target type.
Anyone knows why ?
Thanks,
Guy
- Next message: Lloyd Dupont: "string as lock key?"
- Previous message: Paul Rudin: "Re: ArrayList adapter problem"
- In reply to: Guy Gani: "Re: General Event Handler"
- Next in thread: Paul: "Re: General Event Handler"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|