Click here to Skip to main content
15,891,423 members
Everything / Event

Event

event

Great Reads

by Mark Pelf
Tutorial article on Asynchronous Events invocation in C#
by Arthur Minduca
Domain Events registered by conventions with the container and fired only when the transaction is committed
by Akhil Mittal
This article of the series "Diving into OOP" will explain all about events in C#. The article focusses more on practical implementations and less on theory.
by Mark Pelf
Tutorial on “Events Bubbling” in JavaScript language

Latest Articles

by Mark Pelf
Tutorial on “Events Bubbling” in JavaScript language
by vblover Programmer
Adding ContextMenu's MenuItem to the SystemMenu of Form in Windows Forms Application
by Mark Pelf
Tutorial article on Asynchronous Events invocation in C#
by Vassili Kravtchenko-Berejnoi
Use of System.WeakReference for self-cleanable registration of (short-life) objects

All Articles

Sort by Score

Event 

11 Sep 2022 by Mark Pelf
Tutorial article on Asynchronous Events invocation in C#
23 Apr 2013 by Ian A Davidson
I am sorry that I only saw this question today. I have a several years' experience with FileSystemWatcher (and with the Win32 API functions when using C++ before C#).These are the main areas to look out for:1) As you said, make sure the code that handles notifications is as quick as...
27 Mar 2017 by Arthur Minduca
Domain Events registered by conventions with the container and fired only when the transaction is committed
6 Jan 2017 by Akhil Mittal
This article of the series "Diving into OOP" will explain all about events in C#. The article focusses more on practical implementations and less on theory.
13 Nov 2023 by Mark Pelf
Tutorial on “Events Bubbling” in JavaScript language
24 Feb 2019 by chuck in st paul
This is a utility program for bulk/batch renaming of files that demonstrates using and creating events
27 Jan 2020 by Vassili Kravtchenko-Berejnoi
Use of System.WeakReference for self-cleanable registration of (short-life) objects
19 Oct 2010 by shakil0304003
You can see this link-> Click
6 Apr 2011 by Not Active
You tried something like this?private EventHandler onMyEvent;public event EventHandler MyEvent{add{Foo();onMyEvent = (EventHandler)Delegate.Combine(onMyEvent, value);}remove{Bar();onMyEvent...
17 Jul 2011 by Tarun.K.S
Hi,You can have a look at these articles which were in my Bookmarks list.1) http://www.blackwasp.co.uk/CSharpEvents.aspx[^]2) Second part: http://www.blackwasp.co.uk/CSharpEventAccessors.aspx[^]3) A very detailed article: To learn events, you must also have an idea about delegates....
8 Apr 2012 by Sergey Alexandrovich Kryukov
Outside mouse events might be dispatched to some other application, so they might not logically exist for a regular .NET application. My first response would be this: you don't really need it. The behavior you want would contradict the accepted UI model of the OS; it would also drives your...
18 May 2017 by Jon Campbell
How to utilize WCF to allow a single instance of any WPF application without needing mutexes, extra assemblies, or special "hacks".
8 Mar 2012 by Torsten Tiedt
Avoid event spaghetti code when business logic becomes complex.
10 Feb 2012 by Bertus Bever
Suppressing key and mouse events while loading
13 Apr 2012 by Sergey Alexandrovich Kryukov
I remembered that I completely solved this problem, so I looked at my old code and found it. All the changes in caret position will be caught if you override the virtual method TextBox.OnSelectionChanged. You can also handle the event SelectionChanged, of course. I prefer to subclass the control...
10 Aug 2012 by fjdiewornncalwe
As Wes has pointed out in his comment, the definition of your method is incorrect. If you are responding to a click event on a LinkButton as you are in this case, then the method must have a definition that matches protected void MethodName(object sender, EventArgs e). Yours is using...
10 Aug 2012 by Wendelius
The System.EventHandler delegate expects you to have a method with a specific signature present. See: EventHandler Delegate[^]So your code should probably be like:protected void lnkCustomer_Click(object sender, System.EventArgs e) { ... }Addition:Casting the sender...
19 Jul 2012 by bahman aminipour
Hi everybody, I have a simple UserControl and a Button on it. How can i define a custom click event for my control so that when i use this user contol in the application, clicking the button, raise my custom event?
4 Mar 2010 by Simon P Stevens
This code provides SafeTrigger extension methods as a way of triggering events in a thread safe way.For details on usage, a discussion of reasons and alternatives, and a full solution download see my article on safely triggering events[^]Multiple overloads are provided for convenience to...
18 Oct 2010 by Arindam Tewary
Hi,You can write one method to handle multiple textbox's textchanged method.EventHandler takes the name of the method to be associated with the event. Hence if you mention same name for multiple textchanged, it would work.TextBox1.TextChanged += new...
18 Feb 2011 by Nish Nishant
Adding to John's answer:Two problems in that code (although this may not be your actual code)1. You are not instantiating your FileSystemWatcher anywhere.2. Make OnChanged a non-static method and it will be able to access the a member.Suggestions:1. Make a a List instead of...
10 Mar 2011 by Sandeep Mewara
Using Visual Studio DEBUGGER? What say?
17 Jul 2011 by Richard MacCutchan
Take a look at this article[^] on MSDN. You may also find that a search of the CodeProject articles will find you some useful samples.
13 Sep 2011 by Mohammad A Rahman
It might be helpful,OnPaint[^]Control.OnPaint[^]:)
13 Sep 2011 by Abhinav S
Form.OnPaint overrides the Control.OnPaint event. Read more about this here[^].
21 Oct 2011 by Sergey Alexandrovich Kryukov
Yes, this is well-known problem — C++/CLI is very different. Solution is also well-known, but it might look very unusual: not only you are not allowed to do the check like if(OnCppCliEvent != nullptr), you also never need it!In other words, just delete this check — the code will...
23 Dec 2011 by theanil
i got 2 solutions in code project for raising an event Programmatically, raising an event programmatically[^]How to call "click on column header" event programmatically?[^]
18 Jul 2012 by lukeer
First version: just the console output:private static int Main(){ for( int i = 300; i > 10; i--) { if( i
15 Aug 2012 by Sergey Alexandrovich Kryukov
The idea is very simple. You almost got it, should just think about it.The kind of late binding you use is of the level of plug-in (your "registered" DLL) and the plug-in architecture. You need to look at it as at the whole architecture, and it all will be clear to you. The think is: the...
25 Sep 2012 by OriginalGriff
The possibilities are pretty obvious:1) categoryMember is null, either because CategoryDataGrid.SelectedItem is null, or is not a CategoryTbl,or2) CategoryName is null.Put a breakpoint on the first line of the handler, and step through until you find out which. Then you can either fix...
2 Aug 2013 by Ron Beyer
if (someflag == true) { if (lblsomelbl.InvokeRequired) lblsomelbl.Invoke((MethodInvoker) delegate { lblsomelbl.Text = "1234"; }); else lblsomelbl.Text = "1234"; }Basically you have to change properties that interact with the...
22 Feb 2014 by Sergey Alexandrovich Kryukov
Dave Kreskowiak is right, please see his comment to the question. Nothing is cancelled or disabled.Not only handling Paint event of the PictureBox makes no sense, using PictureBox for rendering graphics makes no sense at all (even though it is possible). This is just a control designed to...
8 Nov 2016 by slavik57
A library of notification based objects for TypeScript/JavaScript
26 Mar 2017 by Danilow
Simulating C# event handlers in Java
17 Jan 2022 by Dave Kreskowiak
That code won't even compile so everything else you said about it doing something doesn't matter. This comparison is not possible and will keep your code from compiling: If Label10.Text >= "1"
8 Feb 2011 by Nish Nishant
Your delegate is not marked public, so it will default to internal. So even though your class is public, and so is the event member within the class, the event type itself will not be accesible. Mark the delegate to be public too.
27 Jul 2011 by OriginalGriff
Don't add a handler for the event if you don't want it?If you don't specify a handler, nothing unusual happens...
5 Dec 2011 by OriginalGriff
Use the Tag property:public Node(){ _nodeID = -1; _nodeName = String.Empty; _nodeLastMessage = new DateTime(1, 1, 1, 0, 0, 0); _nodeExpiredTimer = new Timer(); _nodeExpiredTimer.Tag = this; // Add this line. _nodeExpiredTimer.Interval = 10000; ...
23 Dec 2011 by Sergey Alexandrovich Kryukov
In clarification of other answers:The event objects have a number of limitations compared to delegate instances used directly. One important limitation is: there is only one way to invoke an event: in the code of the class where the event instance is declared. It is not possible to invoke a...
12 Jan 2012 by South 305
I would like to MONITOR an HTML control (HtmlElement) inside a WebBrowserControl. I would like to add EVENTS to the control in order to be notified whenever any EVENT got call(fire) on that control.To simplify my needs here are 3 questions assuming the following single line of code: var...
2 Feb 2012 by Sergey Alexandrovich Kryukov
It looks like this problem is solved in this CodeProject work:Vista Core Audio API Master Volume Control[^].Locate the sentence: "If you just want to be informed when somebody changes the volume settings, you can subscribe to the OnVolumeNotification event".See also:...
16 Jan 2013 by grimbeast
//Casting sender to GenEventvar s = sender as GenEnvent;if (s != null){ //Do your thing}//Check type of sender to be GenEventif(sender is GenEnvent) Console.WriteLine("From registered workout {0}", sender.ToString());
29 Jan 2013 by Alexey Loire
Just managed to solve my problem via using SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL flags in grfAccessPermissions which can be found in EXPLICIT_ACCESS structure.EVENT_ALL_ACCESS - didn't work for some reason ;(Sorrowfully there's not a single manual that describes what values does this...
26 Mar 2013 by nv3
You have probably forgotten to define the static pointer in your cpp file of class CSharedData. There should be a definition:void (*CSharedData::CashierDisplayEventRef)(char Text[256]) = 0;That's where the unresolved external originates from.
26 Mar 2013 by Matthew Faithfull
You've declared a static member CashierDisplayEventRef but have you actaully created such a member?Static members need to be defined and initialised outside the class declaration. Do you have a line in a .cpp file somewhere like:-void (*CSharedData::CashierDisplayEventRef)( char[256] ) =...
9 Apr 2013 by Sergey Alexandrovich Kryukov
This is not really a "solution", but something you should better be aware of; please see these CodeProject articles:FileSystemWatcher - Pure Chaos (Part 1 of 2)[^],FileSystemWatcher - Pure Chaos (Part 2 of 2)[^].—SA
28 May 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
GridViewGridView Class[^].Quote:Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.Inheritance HierarchySystem.Object System.Web.UI.Control ...
12 Jun 2013 by yourfriendaks
try this... protected void grd_Distributor_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", ...
15 Jun 2013 by Ron Beyer
CAD software doesn't use controls for each object/line/rectangle. You use one control called a surface and draw on that surface. You then do your own object management.There is a limit to the number of GDI objects a program can have, and using one object per line/drawing object will quickly...
20 Sep 2013 by Sergey Alexandrovich Kryukov
You cannot prevent pressing any key by the software, quite apparently. :-)You can make some control ignoring some clicks. For example, this is how to filter out all characters but digits:
11 Oct 2013 by ASP.NET Community
The question regarding how to check/uncheck CheckBoxes within a GridView control using JavaScript has been asked many times. Here is a quick
13 Nov 2013 by BillWoodruff
When you define an Event Handler using Lambda notation, the resulting method is "anonymous" in the sense it's not available to be manipulated by the programmer once it has been created unless you keep a reference to it. That's really the same "visibility" logic that applies to anything you...
8 Jan 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Yes ofcourse. Try like below. Use RowDataBound Event.protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){ //check the item being bound is actually a DataRow, if it is, //wire up the required html events and attach the relevant JavaScripts if...
22 Jan 2014 by V.
First of all, why don't you add the button to your user control instead of on the form?if this is really your business case:Add controls to form[^]then you'll need to attach an event handler to it.I suggest you make sure the Button has a unique name or id in it's properties and let...
6 May 2014 by Daniel Lieberwirth (BrainInBlack)
This describes a simple way to create interactive, bitmap based, buttons for WinForm applications.
23 May 2014 by Sergey Alexandrovich Kryukov
The answer is actually in the comment to the question written by Zeee-M and myself.This is what you can use:...
4 Oct 2014 by Sergey Alexandrovich Kryukov
Please see: http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html[^].—SA
1 Jul 2015 by Nuredin Abdella
In this tip, I will discuss how to create, alter, enable, disable and remove MySQL event in order to automate database manipulation tasks.
2 Aug 2015 by Sergey Alexandrovich Kryukov
You never really press multiple keys down at the same time. You only can hold two or more keys down at the same time. Can you see the difference? At low level, keyboard gives out serialized sequence of events, without any "at the same time", but the events are not key presses. Such primary...
5 May 2016 by Karthik_Mahalingam
Try this var buttonId = 0; var classId = 0; var visitedbuttons = []; var lastbutton; function myFunction() { for (i = 0; i
28 Jun 2018 by F-ES Sitecore
The parser has an event (DataReceived) that no-one is subscribed to. The only thing that subscribes to that event is the DataReceivedEventSubscriber, but it subscribes to the event of an instance of CurrentDataDataRespParser that is internal to itself, so the only time that event is going to...
14 Feb 2019 by OriginalGriff
You could remove the event from the handlers list and add it back at the end: Add and remove event handlers dynamically in VB.NET[^] That effectively "disables" it while it's being filled.
13 Dec 2022 by vblover Programmer
Adding ContextMenu's MenuItem to the SystemMenu of Form in Windows Forms Application
3 Mar 2010 by Alaric Dailey
If I am understanding your problem correctly it sounds like you have an even that isn't freed. The way I found to solve this (when using custom objects) was to implement IDisposable and force the events to be cleared.
11 Apr 2010 by hamed-vojdani
Hi allI want to find method name of control eventlike this public partial class MyForm : Form { public MyForm() { InitializeComponent(); this.button1.Click += new System.EventHandler(this.SayHello); } protected...
11 Apr 2010 by Jordy "Kaiwa" Ruiter
Alright, I hope you are ready because Microsoft REALLY doesn't want people to do this :)First we capture the click event and store it in an object secret. Besides that we store property information of events inside eventsProp.System.Reflection.FieldInfo eventClick =...
20 Apr 2010 by William Winner
You need to go back to the article where you found whatever control you're talking about (probably this one: Multiple Selection Control [^]).At the bottom of that page is a forum. Post this question there. This is for general quick answers, not article-specific questions.
16 Jun 2010 by #realJSOP
The first one is the way the IDE does it for you, and the second one is done by people who think it saves them something. I let the IDE do it."equal tab tab" gets it done.
2 Jul 2010 by Christian Graus
Please don't push 'answer' if you're not answering, edit your post, or comment on mine.You can use the Mouse.Capture method to capture the mouse, and then track it's position outside the control it was over from there.
4 Aug 2010 by Svetlin Panayotov
Well, it's not exactly "bubbling", but this should work - in your child window, whenever the survey is finished you can do something like: function closeAndRefreshParent() { window.opener.location = window.opener.location; } ...
4 Aug 2010 by Sandeep Mewara
You can also look at this article, doing almost something similar: Partial update of parent page via AJAX (ASP.NET 2.0) on close of a child window - conditionally[^]
9 Aug 2010 by Simon_Whale
personally I would move your if (dscr.Text == null) MessageBox.Show("You must supply a description");into the next step button e.g. save or update button.
9 Aug 2010 by E.F. Nijboer
Simon_Whale is absolutely right. It is never a good idea to put such a check directly on an edit button because you couldn't even close the form normally without getting the error. The user would be trapped unnecessarily. It is also more user friendly to give the user some freedom until Next...
17 Oct 2010 by Abhinav S
You can get the object of the StackPanel in the code behind,StackPanel myPanel = new StackPanel();myPanel.MouseMove += new MouseEventHandler(myPanel_MouseMove);void myPanel_MouseMove(object sender, MouseEventArgs e) { //Do your stuff here}
19 Oct 2010 by Skeith2005
I'm fairly new to C# and I was curious, is there an event I can call when an application crashes? I have a program that writes and formats .csv files for use in store inventory, but some of these computers are riddled with errors (Not to mention my own noviceness with C#) are causing a few...
19 Oct 2010 by Dylan Morley
I'm guessing this is a Winforms application? You could set up some 'global' error handlers that will trap any exceptions you haven't explicitly handled in your code. In your application startup, have some code along the lines of/// /// Main thread exception handler/// ///...
17 Nov 2010 by Dave Kreskowiak
Screw all the "event" crap and write your own log viewer that scrolls to the bottom of the log by itself. This is extremely easy to do.Events only exist inside the application that is using them. There is no Double-Click event that you can subscribe to that comes from Explorer and lets you...
29 Jan 2011 by Steve Wellens
1> All images come on new line i want them next to each other.Do you mean the user controls? Images by default display inline. You maybe able to change the way the usercontrol displays by setting it's style: style="display:inline" 2> How to detect which radio button is clicked as i...
8 Feb 2011 by Sergey Alexandrovich Kryukov
Events are not raised and caught, they are not exceptions. They are fired and handled. (Don't say, this is just terminology! I am not sure. Very often terminology is indicative of some misconception.) Now, the events ultimately are containers for delegate and invocation mechanism, there is...
5 Mar 2011 by Monjurul Habib
You can use the AutoEventWireup value true or false. By default its value is set to false. We can specify the default value of the AutoEventWireup attribute in the following locations:- The Machine.config file.- The Web.config file.- Individual Web Forms (.aspx files).- Web User...
10 Mar 2011 by Olivier Levrey
Sandeep is right. Just put a break point into both handlers, run your app in debug mode, hit a key and see where you stop first.Normally, your handlers should be called in the same order of the assignements:...{ //first assignement MyEvent += MyEventHandler1; ...
12 Mar 2011 by v.chjen
you can use databinding to bind text in your StatusBar with text in textbox.Than add handler to TextChanged event in textbox
31 Mar 2011 by Keith Barrow
Do you re-create the button at postback? If not the event won't fire properly!
6 Apr 2011 by Toli Cuturicu
Scenario:I have designed a Control inheriting from TextBox.I have implemented an event, which works well (does its job).Problem:I would like my Control to do something (invoke a method to check something and set some properties etc) every time this event is assigned from other class...
19 Apr 2011 by Andrew Rissing
The simplest approach to handling this problem is to perform an InvokeRequired check (assuming WinForms here) and if its required call Invoke.You would need to perform this within your _Scanner_DataEvent method.private void _Scanner_DataEvent(object sender, EventArgs e){ // Check...
19 Apr 2011 by #realJSOP
I'm not sure about your design. Is the scanner multi-thread capable? Can multiple scanner objects access different devices at the same time?
19 Apr 2011 by Sergey Alexandrovich Kryukov
I cannot see what threads should be involved in inter-thread communication. The big difference: if UI thread involved or not. Let's start with UI.If you need to operate UI from a non-UI thread, you cannot do it through any calls (isn't that natural?). Instead, you have to use methods Invoke...
29 Apr 2011 by Sergey Alexandrovich Kryukov
Finally, stop guessing and use the Debugger. Put a break point on your event handlers and under debugger look at the call stack to see where is the events are fired. You will see it in no time. How anyone can find you bug without looking at the code?Better yet, please understand that a main...
18 May 2011 by Yvan Rodrigues
The registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\System\EventLog\EventMessageFile points to a file that contains valid sources, messages and IDs. The OS enumerated its known sources for event messages and didn't find one that matched your entry, so it returned...
19 May 2011 by Sergey Alexandrovich Kryukov
First things to know: there is no barriers between assemblies (unless you artificially create barriers changing assembly permissions). Whatever you can do in one assembly, you can do in reference assembly. You only need to use public or protected (within the same class hierarchy) access...
26 May 2011 by Kim Togo
There is a SystemEvents.TimeChanged[^] event that is triggered when the user changes the time on the system clock.When the program is not running, you can store the value in DateTime.Now.IsDaylightSavingTime and use this to compare at next startup.
4 Jun 2011 by Christian Graus
This code is full of issues. Using Convert.ToInt32 will throw errors if there's not a number in the text box. IF you have an event being thrown, the sender object being passed to the event, is the control that threw it, so you can work out from there which text box it was. An array of...
22 Jul 2011 by Abhinav S
Have a look at the Calendar sample here[^]. Just using SelectedDate as show here[^].Remember though that this is a server control.
22 Jul 2011 by Danny Hulmston
Try this quick solution for C# Windows Forms:DateTime selectedDate = Convert.ToDateTime(monthCalendar1.SelectionStart);textBox1.Text = selectedDate.ToShortDateString();Test it by putting the code within the monthCalendar1_DateSelected event. Try this solution for ASP.NET Web...
23 Jul 2011 by Deaths_eclipsE
Not exactly what i wanted. What I'm to do is have events show in the textbox. For instance if the user's current selection is 28/07/2011 It'll write "meeting friends". Thanks anyway. It gave me a rough idea.
23 Jul 2011 by Eslam Mostafa
i'm fined a nice solution take itstep1:your form should contain1- tow textbox one of them visible=false2- calenderstep2://code under calenderTextBox1.Text = Calendar1.SelectedDate.ToShortDateString().ToString();//this textbox visible=falseif (TextBox1.Text ==...
26 Jul 2011 by Deaths_eclipsE
Thanks. Disn't think of that. Case closed :-)
27 Jul 2011 by Christian Graus
Better than stripping events, is to set flags that tell you in each event handler, if the code should run or not. In key press events, you can also reject the event by setting the Handled property on the eventargs.
13 Aug 2011 by Sergey Alexandrovich Kryukov
There is no such event; there is no a concept of loading of the text box. There is a read-only property System.Windows.Forms.TextBox.Text. The setter of this property fires the event System.Windows.Forms.TextBox.TextChanged. Use it — this is what you need.—SA
21 Sep 2011 by Prerak Patel
Use AddHandlerAddHandler Form.Paint, AddressOf Form_Painthttp://msdn.microsoft.com/en-us/library/7taxzxka(v=vs.80).aspx[^]