473,516 Members | 2,889 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom EventHandler and Windows Forms

Hi All,

I'm hoping someone can help me out. I have a Windows Form dialog (call it
dialog1) that responds correctly to a custom event generated by another
class in my app. Inside this custom event handler that exists inside the
Windows Form object I need to load/display another Windows Form dialog, call
it dialog2. So, I dutifully instantiate Dialog2 and call it's ShowDialog()
method. Dialog2 happens to have a button on it that performs a utility
function which in turn instantiates and calls ShowDialog() on yet another
Windows Form...Dialog3. When Dialog 3 completes it's work, Dialog2 crashes
out, back to an exception handler way back in Dialog1 complainiing that an
External component threw an exception. This is highly reproducible... even
in a test app. Here's another weird part. If Dialog2 is directly
instantiated from a button on Dialog1, then the problem does not occur. I
tried calling Invoke from inside the custom event handler in Dialog1 to call
a delegate method to perform the work, but that makes no difference.

What gives? Any help would be appreciated.

TIA,

--
John Bowman
Verona, WI
Nov 21 '05 #1
4 1507
doesn't sound like a mystery at all. simply, that the error occurs in
dialog3 and you aren't catching any from the dialog2 form. the error throws
you back to the last try/catch/on error statement defined (no matter what
point in code that may have been)...even to the point where nothing is
handled and your app crashes.

the easiest test for the theory is to place an on error resume next in the
interface that calls dialog3.showdialog().

hth,

steve
Nov 21 '05 #2
Steve,

Thanks for the reply. But this is NOT it. That code all works as expected
when we step through it. I think you missed my point that the problem does
NOT occur when the sequence is called directly rather than from the Custom
EventHandler.The error is produced by the system when Dialog2 finishes the
routine that instantiates Dialog3 and calls its ShowDialog(). There are NO
errors until you step past the End Sub in this routine in Dialog2. We have
it narrowed down to something related to calling this sequence from inside
the Custom EventHandler.

John
"steve" <a@b.com> wrote in message news:10************@corp.supernews.com...
doesn't sound like a mystery at all. simply, that the error occurs in
dialog3 and you aren't catching any from the dialog2 form. the error
throws
you back to the last try/catch/on error statement defined (no matter what
point in code that may have been)...even to the point where nothing is
handled and your app crashes.

the easiest test for the theory is to place an on error resume next in the
interface that calls dialog3.showdialog().

hth,

steve

Nov 21 '05 #3

"John Bowman" <jm******@charter.net> wrote
Thanks for the reply. But this is NOT it. That code all works as expected
when we step through it. I think you missed my point that the problem does
NOT occur when the sequence is called directly rather than from the Custom
EventHandler.The error is produced by the system when Dialog2 finishes the
routine that instantiates Dialog3 and calls its ShowDialog(). There are NO
errors until you step past the End Sub in this routine in Dialog2. We have
it narrowed down to something related to calling this sequence from inside
the Custom EventHandler.


It would help if you posted the test app the just reproduces the error, so that
others can se the problem on their system....

LFS
Nov 21 '05 #4
Larry,

Thanks for the response. As I was cleaning up the test app so I could post
it, I found the problem. Basically, I discovered that the thread that Raises
the custom event & triggers the event handler, was using a
System.Windows.Forms.Timer from inside an object that was NOT a Form object
for some unknown reason. When this was changed to a proper
System.Timers.Timer object, all started working correctly.

John

"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...

"John Bowman" <jm******@charter.net> wrote
Thanks for the reply. But this is NOT it. That code all works as expected
when we step through it. I think you missed my point that the problem
does
NOT occur when the sequence is called directly rather than from the
Custom
EventHandler.The error is produced by the system when Dialog2 finishes
the
routine that instantiates Dialog3 and calls its ShowDialog(). There are
NO
errors until you step past the End Sub in this routine in Dialog2. We
have
it narrowed down to something related to calling this sequence from
inside
the Custom EventHandler.


It would help if you posted the test app the just reproduces the error, so
that
others can se the problem on their system....

LFS

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2706
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx. The problem is the article is in VisualBasic. I already get the collection to be recognized as a Data Source by the IDE. It populated the DataGrid...
11
6163
by: Sagaert Johan | last post by:
I have made a custom control that draws a rectangle when the mouse is down, and does nothing when the mouse is up. I set/reset a flag in MouseDown/Mouse up and use this to do the drawing in the OnPaint . The recangle draws correct when i press the mouse, but when i release the mouse the background is not restored What should i do in the...
3
4237
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found several examples on the web. They all seem to have problems, though that I've been unable to resolve. The most promising example I have found is...
8
10071
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for a text box has 6 items, undo, cut, copy, paste, delete and select all. I would like to add one additional paste menu that opens a new sub menu with...
5
1627
by: pswulius | last post by:
Hey everyone, for reasons I can't explain quickly, I'm developing a completely custom OK/OK_CANCEL dialog, though I think many people would benifit from this knowledge. I basically need to re-invent the wheel and provide a simple API like: Result result = CustomDialog.Show( Mode.OK_CANCEL, aMessage ); The problem that I'm not sure how...
1
1986
by: Martin Robins | last post by:
I have developed a custom control that, among others, includes a property that is a collection of "Items". If I place an instance of my control onto a CF form, I can view all of the properties correctly in the property grid and my collection appears with the ellipses ready to open the collection editor. Click on the ellipses and the editor...
11
18075
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with ListView columns so it should be doable, thanks
4
2757
by: Dan Soendergaard | last post by:
Hello fellow developers, I've created a control which derives from the .NET TextBox. I then wanted to add two events to the new control, so I added the following to the control code: public event EventHandler InvalidValueMatched; public event EventHandler ValidValueMatched; But when one of the events is raised I get this exception:
2
1270
by: arevans | last post by:
I built a custom control 'ChooseBox' that inherits from ComboBox. When I select an item from a choosebox control, the selected item does not show up; I mean, the background is blue, but the text is hidden. I have checked my backcolor and forecolor, and don't see anything wrong there. I know this is probably a simple q. Here is the code. Can...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.