Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 21st, 2006, 12:43 AM
Registered User
Join Date: Mar 2006
Location: , , Russia.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default User Control with my event

I've created User Control with my event:

public partial class ucHouse1 : UserControl
    public delegate void MyEngineHandler(int NewIdHouse);
    public event MyEngineHandler IDHouseChanged;

I run this event:

private void cmbHouses_SelectedIndexChanged(object sender, EventArgs e)
      int var_ID_House = (int)this.cmbHouses.SelectedValue;

      if (IDHouseChanged != null) IDHouseChanged( var_ID_House);

On form where I've added my User Control I work with this exent

private void ucHouse_IDHouseChanged(int NewIdHouse)
      this.MyDataSet.tblCustomer[0].ID_House = NewIdHouse;

All work very good. But when I try to close my form I receive AgumentException in event Dispose of my User Control:

   protected override void Dispose(bool disposing)
      if (disposing && (components != null))
base.Dispose(disposing); // <-- Here I receive AgumentException }

Text of Exception:
Object of type 'System.EventHandler' cannot be converted to type 'ucHouse1+MyEngineHandler'.

What I do not correctly ?

Reply With Quote
  #2 (permalink)  
Old May 2nd, 2006, 05:56 PM
Authorized User
Join Date: Jun 2004
Location: , , USA.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts

Hi There,

Put in some generic error trapping. Maybe components.Dispose() already cleaned it out, so maybe try catch would work.

Paul O

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to raise event in user control webpart... tqit ASP.NET 2.0 Basics 1 September 13th, 2006 04:37 AM
Add Windows User control in Web User Control agarwalvidhu C# 0 March 30th, 2006 01:17 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
An activity by user B trigger an event for A bigmish Classic ASP Basics 1 July 3rd, 2004 04:28 PM
Programmatically Loaded User Control Event Handlin cgoldrin ASP.NET 1.0 and 1.1 Professional 4 December 2nd, 2003 09:59 PM

All times are GMT -4. The time now is 11:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.