Wrox Programmer Forums
.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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 21st, 2006, 12:43 AM
Registered User
Join Date: Mar 2006
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 ?

Old May 2nd, 2006, 05:56 PM
Authorized User
Join Date: Jun 2004
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

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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.