Click here to Skip to main content
15,887,676 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Unregistering Event Pin
Rome'26-Apr-07 4:43
Rome'26-Apr-07 4:43 
GeneralRe: Unregistering Event Pin
Scott Dorman26-Apr-07 5:16
professionalScott Dorman26-Apr-07 5:16 
Rome` wrote:
the designer code will be regenerated


If you are using VS2005, it is safe to modify the Dispose method in the .Designer.cs file. Otherwise, you are right and may have an issue (it's been too long since I've used the earlier versions so I'm not 100% sure if they will overwrite the Dispose method when regenerating the designer generated code).

Rome` wrote:
GridVoucher.Click -= new (GridVoucher_Click); be enough


If you double check the code in my previous post, you will see that I am actually calling GridVoucher.Click -= GridVoucher_Click;. There is no new call. Technically, the GridVoucher.Click -= new(GridVoucher_Click); is creating a new event handler delegate with the same signature as the previous one and then unregistering it, which ultimately causes both to be unregistered. It's a little bit quirky that you can do this, but it does work. However, the better approach is to use the GridVoucher.Click -= GridVoucher_Click; syntax as this prevents an additional object from being created. Remember, this is all happening as the class is being disposed, so you want to make sure things happen as quickly and efficiently as possible. You should avoid creating new objects inside the Dispose whenever possible.

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

GeneralRe: Unregistering Event Pin
Dan Neely26-Apr-07 8:50
Dan Neely26-Apr-07 8:50 
GeneralRe: Unregistering Event Pin
Martin#6-May-07 20:31
Martin#6-May-07 20:31 
GeneralRe: Unregistering Event Pin
Scott Dorman7-May-07 4:21
professionalScott Dorman7-May-07 4:21 
GeneralRe: Unregistering Event Pin
Martin#7-May-07 4:38
Martin#7-May-07 4:38 
GeneralRe: Unregistering Event Pin
Scott Dorman7-May-07 4:42
professionalScott Dorman7-May-07 4:42 
GeneralRe: Unregistering Event Pin
Martin#7-May-07 4:48
Martin#7-May-07 4:48 
GeneralRe: Unregistering Event Pin
Scott Dorman7-May-07 4:51
professionalScott Dorman7-May-07 4:51 
GeneralRe: Unregistering Event Pin
Martin#7-May-07 4:54
Martin#7-May-07 4:54 
Questiondatarelation in dataset Pin
shanthivasan26-Apr-07 2:02
shanthivasan26-Apr-07 2:02 
AnswerRe: datarelation in dataset Pin
stancrm26-Apr-07 2:56
stancrm26-Apr-07 2:56 
GeneralRe: datarelation in dataset Pin
shanthivasan26-Apr-07 18:57
shanthivasan26-Apr-07 18:57 
QuestionCheckbox field Pin
Muammar©26-Apr-07 1:56
Muammar©26-Apr-07 1:56 
AnswerRe: Checkbox field Pin
kubben26-Apr-07 2:31
kubben26-Apr-07 2:31 
GeneralRe: Checkbox field Pin
Muammar©26-Apr-07 3:20
Muammar©26-Apr-07 3:20 
QuestionPost-Build-Step: Copy New Files Pin
Tomerland26-Apr-07 1:38
Tomerland26-Apr-07 1:38 
AnswerRe: Post-Build-Step: Copy New Files Pin
Christian Graus26-Apr-07 1:54
protectorChristian Graus26-Apr-07 1:54 
QuestionDataGridView and Animated gif Problem! Pin
mertkan6526-Apr-07 0:45
mertkan6526-Apr-07 0:45 

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.