event-handling

How to sort in a WPF ListBox?

时光毁灭记忆、已成空白 提交于 2019-12-05 12:21:41
The C# 4.0 WPF application, see the code below, shows on startup: abd after clicking the Sort button with btnSort_Click() click event handler: How can I sort in order aaa, bbb, ccc? C# code: public MainWindow() { InitializeComponent(); listBox1.Items.Add("ccc"); listBox1.Items.Add("aaa"); listBox1.Items.Add("bbb"); } private void btnSort_Click(object sender, RoutedEventArgs e) { listBox1.Items.SortDescriptions.Add( new System.ComponentModel.SortDescription("Content", System.ComponentModel.ListSortDirection.Ascending)); } private void listBox1_MouseDoubleClick(object sender,

Is it efficient to use epoll with devices (/dev/event/…)?

最后都变了- 提交于 2019-12-05 10:40:54
I am working on a monothreaded process applet which creates a proxy virtual device (more precisely a virtual Xbox 360 pad); I do manage to create it with the uinput interface, I set it up properly and it works just fine. In order to feed commands to this virtual device , I read events from another real interface (in this case a PS3 pad), and I open the real device file with these flags: fd = open("/dev/input/event22", O_RDONLY); // open the PS3 pad The main loop is something like (minus error checking): while(run) { input_event ev = {0}; read(fd, &ev, sizeof(struct input_event)); // convert

ASP.NET determine which button was clicked inside an updatepanel in page load event

柔情痞子 提交于 2019-12-05 10:13:34
I'm trying to get my head around a page lifecycle issue of an ASP.NET UserControl. What I have is an updatepanel with two buttons in it. Now, in the Page_Load event I need to make a check to see which of the two buttons was clicked. I do know that I should use the click event for this, but this is a case of quite a complex page cycle with dynamically added controls and so on, so forth, so that is not an option, unfortunately :-( I've tried to check on the Request.Form["__EVENTTARGET"] value, but since the buttons are inside an UpdatePanel the value is an empty string (at least I guess that's

Are Event Handlers processed Asynchronously?

两盒软妹~` 提交于 2019-12-05 10:10:50
In VB .NET, when you call RaiseEvent X(), is the function that handles the event X processed asynchronously or synchronously. I was under the impression that RaiseEvent and the processing of the event were Synchronous unless created explictly on another thread. I've been told otherwise though. Events are raised synchronously by default. Since MulticastDelegates are designed to support asynchronous invocation it is possible to invoke the delegates in an event's invocation list asynchronously but this is not the default behavior. I just did some testing also... Public Sub MyHandler() Handles

How to remove and re-attatch EventHandler to controls in c#?

余生长醉 提交于 2019-12-05 10:02:51
I've read this answer . It just tell me how to remove the click event from a button control. I want to know how to change the code (especially the GetField("EventClick"... part!) so I can do the same thing with other controls. For example, I want to remove the TextChanged event of a TextBox . And I also want to know how to re-attach the event handler. public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text.Length < 10) return; MessageBox.Show("do something"); } private void Form1_Load(object

How do you test that a Range in Excel has cells in it?

大憨熊 提交于 2019-12-05 09:53:08
I've found a problem in Excel/VBA in the Worksheet_Change Event. I need to assign Target.Dependents to a Range, but if it has no dependents it brings up an error. I tried testing Target.Dependents.Cells.Count but that didn't work. Any Ideas? Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 OR Target.Dependents.Cells.Count = 0 Then Exit Sub Dim TestRange As Range Set TestRange = Target.Dependents I've also tried "Target.Dependents Is Nothing". Short answer, there is no way to test for dependents without raising an error, as the property itself is set to raise an

How can I listen for “remember me” reauthentication events in Symfony2?

余生颓废 提交于 2019-12-05 09:37:21
Using “normal” — not “remember me” authentication — I can set a success and failure handlers, adding this to the security.yml file: form_login: # ... success_handler: authentication_handler failure_handler: authentication_handler But I couldn't find a way for listening for “remember me” reauthentication, when a user's session is expired and a “remember me” cookie is used to reauthenticate again. Any ideas on how can I achieve this? nezuvian Create a Listener for the security.interactive_login event. That gets triggered on both simple and "remember me" logins (see Symfony\Component\Security

Downcasting non-template base class to templated derived class: is it possible?

帅比萌擦擦* 提交于 2019-12-05 09:01:24
I'm implementing an event system for a game. It uses an event queue, and a data structure to hold all registered event handlers for a given event type. It works fine so far registering handlers, but when it comes to unregistering them (something that will take place when a game object is destroyed, for instance) I'm having a bit of trouble regarding templates and casting. I've defined an EventHandler as some sort of functor, partially based on Szymon Gatner's article on http://www.gamedev.net/reference/programming/features/effeventcpp/ . To be precise, I took the HandlerFunctionBase and

How are async void event handlers called in C#?

霸气de小男生 提交于 2019-12-05 08:14:57
If I declare my event handlers as async void , will they be called synchronously or asynchronously by the .NET framework? I.e., given the following code: async void myButton_click(object sender, EventArgs e) { do stuff await longRunning() do more stuff } Can I be sure that the "do stuff" line will be executed on the GUI thread? Event handlers will be called synchronously and doesn't wait(await) till the event handler completes, but waits till the event handler returns. If previous sentence was confusing enough, I'll try to explain it clear. Asynchronous methods completes when all the await

How to override event handler function of child component from parent component in react.js

萝らか妹 提交于 2019-12-05 07:56:35
/** @jsx React.DOM */ var Button = React.createClass({ handleClick: function(){ console.log(' FROM BUTTON') }, render: function() { return <input type='button' onClick={this.handleClick} value={this.props.dname}/>; } }); var Text = React.createClass({ render: function() { return <input type='text' onClick={this.handleClick} value={this.props.ival}/>; } }); var search = React.createClass({ handleClick: function() { console.log('searching') }, render: function(){ return ( <div> <Text/> <Button dname={this.props.dname} onClick={this.handleClick} /> </div> ); } }); React.renderComponent(<search