Click here to Skip to main content
15,913,854 members
Everything / Event handler

Event handler

event-handler

Great Reads

by chuck in st paul
This is a utility program for bulk/batch renaming of files that demonstrates using and creating events
by Jon Campbell
How to utilize WCF to allow a single instance of any WPF application without needing mutexes, extra assemblies, or special "hacks".
by Dev Leader
Secret of Task EventHandlers
by DarkTyranno
A small application which converts a .nfo text file and views it in a custom form with music and automatic scrolling text!

Latest Articles

by Dev Leader
Secret of Task EventHandlers
by yutaraa
Get, move, copy and delete event handler delegates of Windows form controls.
by chuck in st paul
This is a utility program for bulk/batch renaming of files that demonstrates using and creating events
by Jon Campbell
How to utilize WCF to allow a single instance of any WPF application without needing mutexes, extra assemblies, or special "hacks".

All Articles

Sort by Score

Event handler 

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
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".
14 May 2019 by OriginalGriff
No, you don't. Trust me on this. If you start handling text changed events in your C# code, then your user is in for a slow and uncomfortable user experience - as every key he types has to do a round trip to the server in order to be processed, and that's slow. Very slow. It also requires a full...
30 Jul 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
As far as I understand, you are populating the TextBox when LinkButton is clicked. So, you must be binding the Primary Key value of each row in GridView.Else bind that by using the DataKey property of GridView.Now, try to get the DataKey of the Row, when LinkButton of that Row is...
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...
13 Sep 2013 by CHill60
C# is case sensitive - rename your function from button1_click to button1_Click
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:
8 Jan 2015 by OriginalGriff
Um...you did notice the sender parameter?Cast the sender as a Button, and you should be able to access the ID property for the specific button that was clicked.
29 Mar 2016 by Sergey Alexandrovich Kryukov
You have to use an event wait handle object. No way you should do Sleep, any spin wait, nothing like that. If you wait for some object, your thread goes to a wait state: it is switched off and not scheduled back to execution until it is waken up, spending zero CPU time in wait state. You can...
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...
22 Jul 2018 by Jochen Arndt
The data received handler is executed in another thread. That is why you have to use Invoke to update the content of your text box from. Similar applies to the DataToSetandGet variable used there to store the received string. You can't use it from other threads (like the GUI / main thread as in...
25 Jan 2022 by Tony Hill
If it is a static method you should call it like this. protected void CertLogin_Click(object sender, EventArgs e) { CertSelect.GetClientCertificate(); }
25 Jan 2022 by OriginalGriff
To add to Tony's solution, let me explain the difference between static and non-static objects. C# is all about classes: everything is part of a class. But they aren't all the same. If you think of cars instead of computers for a moment, you...
1 Oct 2012 by Sergey Alexandrovich Kryukov
Actually, MouseDown and Click events do not interfere. As you could notice, the click event is invoked after the MouseUp event, so MouseDown and Click are totally isolated. You handle them in a usual way.Just for your understanding: your button1_Click or button1_MouseDown are not events, but...
7 May 2013 by KarstenK
i guess your threads are blocking the network api.why arent you making some outout or use your debugger...
7 May 2013 by Jochen Arndt
Did you report errors and terminate the thread when a function call fails?There is at least one wrong call that should result in an error return (best case) or undefined behaviour (worst case):WSAWaitForMultipleEvents(2, &hEvent, FALSE, WSA_INFINITE, FALSE);You are passing 2 for the...
2 Jun 2013 by AlphaDeltaTheta
When you minimize and maximize your applet (in applet viewer or webbrowser), a fresh call to update is made after clearing the entire screen. So in update, you only paint the last line... therefore all your lines disappear. Think of some alternate mechanism such as storing all lines in a stack...
30 Jul 2013 by Kunal Ved
Hello friends , I have got an Asp.net form , in that I have Submit button that inserts the textbox data to the data base and binds the gridview . In the grid view I have a link button that fills the text box for the selected row of that gridview. Now on the same submit button I want to fire...
21 Sep 2013 by phil.o
Technically, you are supposed to expose us a problem and ask for a formal question.Anyway, your textMouseDown method has an invalid signature if you want to use it as an eventhandler for MouseDown event:Private Sub TextMouseDown(sender As Object, e As MouseEventArgs) Dim myLabel As...
21 Sep 2013 by Fredrik Bornander
You need to change the signature of your textMouseDown method to match that of the event you're wiring up.Something like this might work for you; Dim textControl() As Label 'Array of label objects Dim txtcnt As Integer Public Sub addTextControl() txtcnt = txtcnt +...
1 May 2014 by Richard MacCutchan
I already explained the issue in your previous question at forrtl: error (200): program aborting due to window-CLOSE event[^]. You cannot capture Windows events/messages in a console program.
29 Mar 2015 by Fredrik Bornander
It's a little bit difficult understanding exactly what you want, but I think it's something like this;When button 1 is pressed, store some value in a variable, somewhere.When button 2 is pressed, use the value stored by pressing button 1, somehow.If that's the case something like...
22 May 2016 by OriginalGriff
The ToolStripComboBox doesn't have a SelectedValue changed - it only has the SelectedIndexChanged event.ToolStripComboBox Events (System.Windows.Forms)[^]Even if it did, the first click would raise it in the same way that it raises an index change.To avoid the "first call" if it's a...
7 Dec 2017 by Shaynec
Hi, I've run into an issue that has me scratching my head and I'm hoping somebody has experienced a similar issue... I have a user control that has a custom event handler. When adding a handle to this event from a separate winforms project, visual studio crashes with the below exception, ...
5 Jun 2018 by OriginalGriff
Please, look at your code! Why would you write this: SerialPort port = new SerialPort(); ... if (port.IsOpen) { port.Close(); port.Dispose(); } port.Open(); If it's a new port, it can't be...
25 Feb 2019 by Maciej Los
Please, read this: The Updated .NET Core Event Pattern | Microsoft Docs[^]
22 Jan 2020 by Richard Deeming
ItemDataBound is only fired when the item is being bound to the data source. That only happens on the initial load; when you click the button to post back to the server, the control tree is recreated without databinding, so the event won't fire. ItemCreated would be the event to use to wire up...
10 Aug 2021 by BillWoodruff
Please ask yourself if you intend to write code only you will understand: if the answer is "no," read on. If you want to get a job as a programmer in the future, please read on. A UserControl is a ContainerControl; so is a FlowLayoutPanel. You...
30 Aug 2021 by Richard Deeming
For something like this, the "best" approach is probably to use event delegation: https://javascript.info/event-delegation[^] document.querySelector('.fruits').addEventListener("click", function(event){ const target =...
14 Jun 2016 by Member 11597857
I thought this would be simple, but I've gone in circles.When the user selects any row in a datagridview I want to switch the selection to the first column. A SelectionMode of either FullRowSelect or CellSelect would be fine (I've tried both).What I have tried:I've tried triggering...
5 Nov 2012 by jeyamothi
Hi, Frequently receive the following error in my application "Cannot open log for source 'xxx'. You may not have write access." This is in Windows 2008R2.Kindly help me.thanks in advance.
5 Nov 2012 by manognya kota
Hi,Following the below steps must help youhttp://mossipqueen.wordpress.com/2008/08/04/cannot-open-log-for-source-you-may-not-have-write-access/[^]
4 Dec 2012 by Samsi Y
Hi All, Very Good Morning..I got a small problem when handling the Unbeforeload.My Problem: Based on Some count i need to show a pop-up window and if the count equals, I need to cancel the pop-Up.Can i handle "X" button in Pop_Up window. If the user clicks on it, is it possible to...
5 Dec 2012 by VishwaKL
http://mattberseth.com/blog/20...
12 Feb 2013 by Janani Muthaiyan
How to define hover/ MouseEnter Event for Asp button? I dont wanna use Jquery.. I want to write event in the code behind the asp.. Example:protected void Page_Load(object sender, EventArgs e) { PanelID.Visible = false; }protected void...
12 Feb 2013 by Anurag Sinha V
Hi,You might wana check the below link.http://social.msdn.microsoft.com/forums/en-US/winforms/thread/aa431c76-df11-4d72-9255-191b28dce9a3[^]Hope it helps.regardsanurag
16 Mar 2013 by Mujahid Islam
I have a problem to compiling this code im new to java and did'nt understand waht is problem please help me code is attached.import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Cal implements ActionListener{JFrame frm;Container c;JLabel...
16 Mar 2013 by H.Brydon
You have public void actionPerformed(ActionEvent e) defined twice, with 2 different implementations.[ha ha] No, actually you have defined it 3 times.
10 Apr 2013 by vasantha kumar S
I want to have a image below a cursor when I drag and drop icons from a wxListctrl to a wxPanel.But when I try doing it i am not getting the image.Please help me out.Thank you.wxImageList* n1=ListCtrl1->GetImageList(wxIMAGE_LIST_SMALL);wxBitmapDataObject...
10 Apr 2013 by vasantha kumar S
I am Developing a windows application. IDE: CODEBLOCKSIn codeblocks there is no "mouseover event" to capture the mouse event.please help me out.Thank you
10 Apr 2013 by CPallini
Quote:In codeblocks there is no "mouseover event"Sure, but Windows API do provide the functionality. Just have a look at the documentation[^].
20 Apr 2013 by anju_g
Hi,I am using delegates and event handlers. public delegate void StringReadEventHandler(string text); // Event to notify of a string read from stdout stream public event StringReadEventHandler StdoutTextRead; // Event to notify of a string read from stderr...
20 Apr 2013 by Richard MacCutchan
Use a TextWriter[^].
9 May 2013 by ayesha hassan
I am working on newtwork event based socket application. When client has sent some data and there is something to be read on the socket, FD_READ network event is generated.Now according to my understanding, when server wants to write over the socket, there must be an event generated i.e....
10 May 2013 by Richard MacCutchan
See http://msdn.microsoft.com/en-us/library/windows/desktop/ms741540(v=vs.85).aspx[^] for a complete description of how these events are generated and consumed.
26 May 2013 by AG007
public class xy extends Applet implements MouseListener,ActionListener{ Button b; int x1, y1,x2,y2; public void init() { b=new Button("Draw Line"); add(b); x1=y1=x2=y2=0; b.addActionListener(this); } public void actionPerformed(ActionEvent...
28 May 2013 by PleaseHelpCP
Hi,I am creating checkboxes dynamically. I want to handle its CheckedChanged eventCheckBox cb = new CheckBox();cb.ID = dvw["Val"].ToString();cb.Text = dvw["Txt"].ToString();cb.AutoPostBack = true;cb.CheckedChanged += new EventHandler(cb_CheckedChanged)How to pass...
29 May 2013 by Maciej Los
have a look here: CheckBox.CheckedChanged Event[^]. There you'll find an example.
29 May 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
No, you can't add an extra parameter to an existing event handler.Find some other way to do what you want to achieve.Refer - Delegates and Events[^] to explore more.
1 Jun 2013 by Ivel97
I'm using this library for transitions: https://code.google.com/p/dot-net-transitions/I'm trying to handle this event: https://code.google.com/p/dot-net-transitions/wiki/CodingWithTransitions#Using_the_TransitionCompletedEventIt says its raised by the background transition thread when...
14 Jun 2013 by Michelle Phoenix
Hello,I am building a form which has various controls on it, and each control has various methods that are handled, such as onLoad, Click etc. When certain methods are fired, I need to write a log entry that that specific control's _something method was fired.However, instead of adding...
14 Jun 2013 by Mehdi Gholam
Read the following :http://msdn.microsoft.com/en-us/library/ms228976.aspx[^]http://msdn.microsoft.com/en-us/library/system.reflection.eventinfo.addeventhandler.aspx[^]
26 Jul 2013 by Sushil Mate
You have form? Create the KeyDown[^] Event. From http://stackoverflow.com/a/3334956[^]public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.BringToFront(); this.Focus(); ...
30 Jul 2013 by Dheeraj_Gupta
As i am understanding your question. you want to use same submit button for both tasks insert and update. For this you need to have an hidden field which will say that what operation you are now going to perform by clicking on submit button. like in hidden field you can provide the row no or...
30 Jul 2013 by Sampath Lokuge
You may try like below :1. When you insert a text box value for the first time, you don't have any primary key associated with that transaction.So you can go for insert SP.2. But When you update the record,you can easily check that record's primary key vale and If it's there then you can...
10 Aug 2013 by danar_kalari
I have a problem. While I am adding an event handler from code behind to a button the event never gets fired. But when I add it from when creating the button tag it works perfectly and I am creating the button from code behind and I adding it to table. ...
10 Aug 2013 by Srinivas Kalabarigi
Take backup of your button event code... delete the button from design mode... add new button and double click it and paste the code... This will fix the issue...
13 Sep 2013 by Code Mirror
I am creating a win form application in which i need to make button at run-timethis is code how i am doing Button button1= new Button(); panel1.Controls.Add(button1); button1.Location=new Point(220,457);button1.Name="btnnextimage11";button1.Size=new...
13 Sep 2013 by Code Mirror
Thanks a lot to helping hands :)I am posting my final code to create a Button dynamically and related stuff too{Button button1= new Button();button1.Location=new Point(220,457);button1.Name="button1";button1.Size=new Size(118, 39);button1.Text = "Click This button...
20 Sep 2013 by Divakar Raj M
I have a WebDateChooser textbox which automatically fills up with the current date when the page loads. I can edit this textbox and enter a custom value date. My problem is that after entering a custom date, if i press Enter key and then click outside the textbox, it reverts back to the default...
20 Sep 2013 by V.Lorz
Sergey's solution is what you need in this case, but take also a look at this JQuery plugin here http://code.google.com/p/jquery-ui-plugins/wiki/TextInput[^] as it could be usefull for future references.If you need more details on keypresses processing, this link has also some more...
4 Nov 2013 by OriginalGriff
Probably, you don't want to add a new handler each time the user presses the button, as you appear to be doing now.You do realize that "+=" for an event adds a handler to the chain? And that if you have the same handler in the chain 8 times, it will get called eight times every time the...
4 Nov 2013 by Ananya Malik
hiI have created a user control containing a button. I want to know if I can call this user control on button click in the user control? if yes, how?thanks,Ananya
4 Nov 2013 by OriginalGriff
That's not exactly clear, but I'll try and explain the various possibilities for what you mean:You can click the Button in the UserControl and raise an event in the UserControl which refers to the button: just add an event handler in the usual way and the sender parameter will contain the...
4 Nov 2013 by Bhuvanesh Mohankumar
Hi,I am not clear about the requirements.As per my understanding, you have a User Control and you have a Button in that control.You need to Fire an event when the button is clicked inside the user control.The Fired event should do some task with your Code Behind at the same time,...
29 Jan 2014 by Purple Ellie
Due to the way our CMS works all bespoke pages have to be in a compiled class library (VB.NET). I need to be able to update a datatable in a Session based on the selected value of a dropdown list in a GridView.Either my SelectedIndexChanged event handler is not firing, or there is a problem...
25 Feb 2014 by Member 10334528
Hi, I am currently working on a C# Windows Forms Application within Visual Studio Express 2012.I have a video, which has it's parent set to a Panel the exact same size as the video (Basically a container for the video). What I am after is the video to have a click event handler so a certain...
25 Feb 2014 by Krunal Rohit
I would suggest you to look at ContextMenuStrip[^], which represents a shortcut menu for the any control associated with it.And how to do that, that is pretty simple. You should play around with the property of the control after adding context menu in your application. But still, look at...
12 Mar 2014 by Ashwani Gusain
if a have an eventHandlar shall i call it from If conditionif (instance.NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(instance_NavigateError))but its not working, actually i need to get response whether its calling or not?please help if u have any other...
11 Mar 2014 by OriginalGriff
No, you don't do that.There is no point in testing the value of a event handler addition: it will never be false because it does not return a bool value. It doesn't return any value! So all you will get is a compiler error about not being able to convert a void to a bool...And you don't...
27 Mar 2014 by Divakar Raj M
I am trying to interactively change button properties in the UI visually. I have a sole button in my Windows Forms application and this is my code for the button clickprivate void button1_Click(object sender, EventArgs e) { button1.BackColor = Color.Red; ...
6 Apr 2014 by george4986
i have an invoice form with a grid for items,loaded from a child form on key press.keypress code in parent: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.F11)) { childform obj = new childform...
7 Apr 2014 by george4986
I have added following code in child forms onload event and now its working//////////fnd_item , is the search control fnd_item.SmartTab = false;
16 Apr 2014 by Sergey Alexandrovich Kryukov
Usually "create… programmatically" means that your code creates something during runtime, otherwise "create an event" would mean "create a new (or updated) code with added event member". Event is a member of some control type (or any other type), you cannot add it "programmatically". Just...
7 Jun 2014 by Member 10528344
I am using NAudio library to capture the audio signal and do the FFT.It sort of working. It can captured audio and do the frequency analysis. but what I want is :playing a tune for 5 seconds, during a second, capture raw data and do FFT. and then check fundamental frequency. and repeat...
9 Jun 2014 by Krishnananthan Vijayaretnam
I've added an user control inside a datagridview row using a Custom Cell. Then I tried to pass a button click from the user control to get the value of the clicked button. This is what I tried. private void InsertRow(Vdine.PosApp.UI.Models.OrderModule.OrderManagementModel...
13 Jun 2014 by C#Programmer2012
I implement a custom control that handle post back event:namespace CalendarControls{ [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] public class CalendarPostback : WebControl, IPostBackEventHandler { ...
16 Jun 2014 by Muhammad Taqi Hassan Bukhari
I have made a web form on asp.net, and a submit button. When first time i open the form and fill data and click on submit form. the data goes into database successfully.Then after i have write code to refresh the page, after refreshing when i fill the form and now click on submit button,...
21 Jul 2014 by Member 7894058
Hi,In my VB.Net form, I'm trying to create an event (leave event)for a custom text field. I'll have to raise the event when the focus is leaving the textbox. It displays in the event list but doesnot fire when I want to, like leaving the textfield. Please help me with this.My custom...
21 Jul 2014 by kasbaba
Is this a custom control you are using?If you have the control source, you can look up the RaiseEvent handler and see if it points correctly to the TextBoxControl_Leave event.If nothing works - you can always use the Enter property of other controls to accomplish what you are trying to...
15 Sep 2014 by Confucius II
Hi, I'm a newbie to Orchard CMS. My problem is that I have created a couple of custom modules on my Orchard site, but am so far unable to raise events and communicate between these modules.From what I’ve read, the EventBus Pattern and IEventHandler is the best way to go about this, but am...
15 Feb 2020 by jchacon28
I finally managed to get my GUI setup, and the listeners registered. I have a Student class, a StudentDemo class, and a StudentInfoWindow. In the StudentInfoWindow class i have a addButton, when i click it, it grabs the info from the text fields, creates a student object, adds it to an array...
22 Oct 2014 by Spidy1
Hi. I have a windows form program that updates info when an existing activesync connection is active.I'd like to write an event handler that will automatically update the form when a new Mobile 6.5 device is cradled.Does anyone have a complete example of this?All the code snippets...
23 Oct 2014 by Spidy1
I solved the crossthreadmessagingexception by using a delegate.private void m_rapi_RAPIDisconnected() { Invoke((new updateFormDelegate(updateForm))); } private delegate void updateFormDelegate(); void...
8 Jan 2015 by Ali Albasri
Greetings to you allI have this table in asp.net and i`m creating dynamic rows for certain data of specific user, and I`m creating dynamic buttons for each row.I want to store each ID the of each row of the data in the button ID property of the button (because there is no tag property)...
15 Feb 2015 by Sergey Alexandrovich Kryukov
Such problems are solved very simply: get rid of PictureBox in all cases except simple presentation of a static picture. Such a simple task as setting a pixel is already the beyond the area when this control is useful. In all other cases, it only presents extra hassles, not giving anything in...
23 Feb 2015 by Sergey Alexandrovich Kryukov
I don't think your forms are really child and parent. Without setting Forms.TopLevel to false (don't do it!), you would get an exception at attempt to set any form's Parent.It looks like a popular question about form collaboration. The most robust solution is implementation of an appropriate...
22 Mar 2015 by Sergey Alexandrovich Kryukov
As the question turned out to be very popular, and my previous answers often were not well understood, probably were not clear enough, I decided to write a Tips/Trick article complete with detailed code samples and explanations: Many Questions Answered at Once — Collaboration between Windows...
29 Mar 2015 by Sergey Alexandrovich Kryukov
There is nothing more wrong that this cast. System.Windows.Forms (too bad you did not indicate what UI library you are using) windowed control wrap HWND; it cannot be a reference in principle, HWND is a native (unmanaged) code handle. In this library, HWND is of course...
18 May 2015 by hosamdahb
Hello,i make an event handler to call a function when row changed, it seems i did something wrong or still missing and i copied the relative code only to not interrupt you, so please help me.DataTable TableX= new DataTable();// do required code to fill the data table and already...
19 May 2015 by hosamdahb
the issue fixed when i moved the adding of event handler each time before filling the data table inside the DataTable fill instead of putting it once in the form load, i don't know why but this is the case!!
13 Jun 2015 by Zon-cpp
Hi,I have a problem to use a managed dll (is built by C#) in a native VC++ code.I can't fire the events of that dll in my VC++!I Registered that dll and import it in VC++ by:#import "..\..\EventDll.tlb" raw_interfaces_onlyand I call other functions of that dll...
26 Aug 2015 by Zon-cpp
Hi, I want to use a dll in my VC++ project. The Dll, have some functions and some events. how do i handle events of dll in my project?name of event is: TestEvent(int i , string msg) when i call test() function of Dll, the event will be called.The Dll is written by C# whit this...
8 Sep 2015 by Ajith.Kerala
USB thumb drives USB harddisks USB DVD writer USB Bluetooth devices USB headsets usb mouse USB keyboard USB webcams / camerasJust want to detect any sort of usb device using event handler...Would appreciate any help... WqlEventQuery...
22 Feb 2016 by Member 12112067
I have an application which works on a 10 ms cycle (every 10 ms all the functions are run so it almost behave like an embedded controller). There is a function in my code which is more expensive (in terms of execution time) than I want. This function is called sendECSResponce (This send a string...
22 Feb 2016 by Philippe Mori
It is hard to make sense of that code...You raise the event in SomethingHappened but that method is not called anywhere.It look like you are trying to explicitly call EventThrower constructor method (just after the comment sending message). I'm surprise that this code would even...
29 Mar 2016 by George Swan
I feel that using the relatively new async feature of C# is the best way to implement asynchronous methods because it provides an exit point for the method when it completes. You can use it like this //subscribe to the event button.Click += MyEventHandlerAsync; // When the event fires...
24 Apr 2016 by hamidsos
I have device that provides some real-time events, the manufacturer give me a dll for use that events and develop programs based on that device.here is some of properties and events of that dll: [ClassInterface(0)] [ComSourceInterfaces("zkemkeeper._IZKEMEvents")] ...
22 May 2016 by Trader999
Sorry if this is a simple question, but how do I raise a SelectedValueChanged event on a toolstrip combobox? In the combobox properties I can see a list of events, but not the SelectedValueChanged event.I need to trigger some code when a user changes the selected item, not when the combobox...