Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Disabling an event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dom - 06 Mar 2008 19:25 GMT
In a DataGridView, I allow the user to change a cell, which fires the
CellValueChanged event (which I use to validate the cell contents),
followed by the EndCellEdit event, which I use to doctor the entry
(eg, change to upcase, etc).  The problem is that when I doctor the
cell contents, the CellValueChanged event is fired a second time.

I want to do the following:

In CellClick ...
[Turn off the CellValueChanged event]
BeginEdit (true);

In EndCellEdit ...
[Turn on the CellValueChanged event]
doctor the contents

The question is, how do I turn off an event.  I can think of two ways;

1.  Use a flag.
2.  m_Event = new DataGridViewCellEventHandler (ProcName);
   x.CellValueChanged -= m_Event
   x.CellValueChanged += m_Event

Is one way better / safer than the other?

Dom
Marc Gravell - 06 Mar 2008 19:45 GMT
Well, the first would be quicker... the second involves lots of
delegate operations (delegates are immutable, so += and -= involve
creating new extended/abbreviated multi-cast delegates).

Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.