Click here to Skip to main content
15,899,007 members
Home / Discussions / C#
   

C#

 
GeneralRe: setting large amount of text in textbox Pin
Marek Grzenkowicz26-Apr-07 3:42
Marek Grzenkowicz26-Apr-07 3:42 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:02
professionalV.26-Apr-07 4:02 
GeneralRe: setting large amount of text in textbox Pin
.jpg26-Apr-07 4:09
.jpg26-Apr-07 4:09 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:15
professionalV.26-Apr-07 4:15 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:12
althamda26-Apr-07 4:12 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:21
professionalV.26-Apr-07 4:21 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:25
althamda26-Apr-07 4:25 
GeneralRe: setting large amount of text in textbox Pin
mav.northwind26-Apr-07 9:52
mav.northwind26-Apr-07 9:52 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 22:58
althamda26-Apr-07 22:58 
GeneralRe: setting large amount of text in textbox Pin
mav.northwind27-Apr-07 8:16
mav.northwind27-Apr-07 8:16 
GeneralRe: setting large amount of text in textbox Pin
lmoelleb26-Apr-07 19:50
lmoelleb26-Apr-07 19:50 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:39
althamda26-Apr-07 4:39 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:44
professionalV.26-Apr-07 4:44 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:46
althamda26-Apr-07 4:46 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:51
professionalV.26-Apr-07 4:51 
GeneralRe: setting large amount of text in textbox [modified] Pin
althamda26-Apr-07 4:59
althamda26-Apr-07 4:59 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 7:37
professionalV.26-Apr-07 7:37 
QuestionPrinting PDF document from C# Pin
PatrickMeinguet26-Apr-07 2:20
PatrickMeinguet26-Apr-07 2:20 
AnswerRe: Printing PDF document from C# Pin
kubben26-Apr-07 2:28
kubben26-Apr-07 2:28 
QuestionUnregistering Event Pin
Rome'26-Apr-07 2:09
Rome'26-Apr-07 2:09 
AnswerRe: Unregistering Event Pin
stancrm26-Apr-07 2:54
stancrm26-Apr-07 2:54 
AnswerRe: Unregistering Event Pin
Nouman Bhatti26-Apr-07 3:07
Nouman Bhatti26-Apr-07 3:07 
GeneralRe: Unregistering Event Pin
Rome'26-Apr-07 3:47
Rome'26-Apr-07 3:47 
GeneralRe: Unregistering Event Pin
Scott Dorman26-Apr-07 4:02
professionalScott Dorman26-Apr-07 4:02 
AnswerRe: Unregistering Event Pin
Scott Dorman26-Apr-07 4:12
professionalScott Dorman26-Apr-07 4:12 
The proper way to do this is to place the code to unregister the event handler in the Dispose method.

I'm going to assume that GridVoucher is not a custom control, user control, or form, and is, instead, a standard UI control (like a listbox). That being said, the form (or user control) that contains this control will have a Dispose method (if you are using VS2005, look in the .Designer.cs file for it). This method should look something like this:
C#
protected override void Dispose(bool disposing)
{
   if (disposing && (components != null))
   {
      components.Dispose();
   }
   base.Dispose(disposing);
}
You need to modify this method to look similar to this:
C#
protected override void Dispose(bool disposing)
{
   if (disposing && (components != null))
   {
      components.Dispose();
   }
 
   if (disposing)
   {
      if (GridVoucher != null)
      {
         GridVoucher.Click -= GridVoucher_Click;
      }
   }
   base.Dispose(disposing);
}
What this does is tell the Garbage Collector (GC) that when the form (or user control) is disposed (and not running as part of a finalizer, which is another part of the garbage collection process) that it also needs to remove the event handler if the GridVoucher object exists and is not null.

-----------------------------
In just two days, tomorrow will be yesterday.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.