event-handling

WPF button click in C# code

白昼怎懂夜的黑 提交于 2019-11-29 02:16:27
问题 I have an array of button which is dynamically generated at run time. I have the function for button click in my code, but I can't find a way to set the button's click name in code. So, what is the code equivalent for XAML: <Button x:Name="btn1" Click="btn1_Click"> Or, what should I place for "????" in the following Code: Button btn = new Button() btn.Name = "btn1"; btn.???? = "btn1_Click"; 回答1: Button btn = new Button(); btn.Name = "btn1"; btn.Click += btn1_Click; private void btn1_Click

How to work with delegates and event handler for user control

我只是一个虾纸丫 提交于 2019-11-29 02:11:22
I have created a user control that contains a button. I am using this control on my winform which will be loaded at run time after fetching data from database. Now I need to remove a row from a datatable on the Click event of that button. The problem is that how do I capture that event in my form. Currently it goes in that user control's btn click event defination. You can create your own delegate event by doing the following within your user control: public event UserControlClickHandler InnerButtonClick; public delegate void UserControlClickHandler (object sender, EventArgs e); You call the

JSpinner Value change Events

风格不统一 提交于 2019-11-29 02:11:07
问题 How to make the update immediately when the jSpinner value was changed. ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { jLabel.setText(e.getSource()); } }; spinner1.addChangeListener(listener); The code above doesnt change the label text automatically, it required you to click again anyplace to update. 回答1: The answer is to configure the formatter used in the JFormattedTextField which is a child of the spinner's editor: formatter

Handling 'ctrl+s' keypress event for browser

允我心安 提交于 2019-11-29 02:09:50
I was trying to implement the CTRL + S feature for a browser based application.I made a search and came across 2 scripts in the following to questions Best cross-browser method to capture CTRL+S with JQuery? Ctrl+S preventDefault in Chrome However,when I tried to implement it,it worked but,I still get the default browser save dialog box/window . My Code:For shortcut.js shortcut.add("Ctrl+S",function() { alert("Hi there!"); }, { 'type':'keydown', 'propagate':false, 'target':document }); jquery hotkeys.js $(document).bind('keydown', 'ctrl+s', function(e) { e.preventDefault(); alert('Ctrl+S');

Event handler in DataTemplate

前提是你 提交于 2019-11-29 02:08:37
I have WPF ComboBox inside a data template (a lot of comboboxes in listbox) and I want to handle enter button. It would be easy if it was e.g. a button - I would use Command + Relative binding path etc. Unfortunately, I have no idea how handle key press with a Command or how to set event handler from template. Any suggestions? You can use the EventSetter in the style you are setting the template with: <Style TargetType="{x:Type ListBoxItem}"> <EventSetter Event="MouseWheel" Handler="GroupListBox_MouseWheel" /> <Setter Property="Template" ... /> </Style> levanovd I've solved my problem by using

Why do you have to pass the event object as a parameter?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 01:39:14
问题 I'm learning how to manipulate events in JavaScript and I'm wondering "why do you have to pass the event object as a parameter (argument) into a function when using event handling?" Here's an example of what I am talking about: <script type="text/javascript"> document.getElementById('button_1').onclick = (function (event) { alert("The event is: " + "on" + event.type); }); </script> I wrote the code above and I pretty much understand what it does. I just don't understand the whole (event)

How to real time display input value with jQuery?

二次信任 提交于 2019-11-29 00:46:39
问题 <input type="text" id="name" /> <span id="display"></span> So that when user enter something inside "#name",will show it in "#display" 回答1: You could simply set input value to the inner text or html of the #display element, on the keyup event: $('#name').keyup(function () { $('#display').text($(this).val()); }); 回答2: A realtime fancy solution for jquery >= 1.9 $("#input-id").on("change keyup paste", function(){ dosomething(); }) if you also want to detect "click" event, just: $("#input-id")

Event handler for editing a Google Maps Polyline?

家住魔仙堡 提交于 2019-11-29 00:33:22
问题 I'm looking for an event that fires while you are editing a Polyline in Google Maps, similar to the 'drag' event on Markers. I've found the 'capturing_changed' event, but it seems to fire on dragstart and dragend, not on drag. As is I'm having to reinvent the wheel by allowing a Marker to be dragged and updating the Polyline based on where the Marker is, basically reinventing editable Polylines. I'd like to be able to add Markers, which editable Polylines do smoothly, but I have to be able to

Backbone.js: how to unbind from events, on model remove

痞子三分冷 提交于 2019-11-29 00:09:11
in backbone we have an app that uses an event Aggregator, located on the window.App.Events now, in many views, we bind to that aggregator, and i manually wrote a destroy function on a view, which handles unbinding from that event aggregator and then removing the view. (instead of directly removing the view). now, there were certain models where we needed this functionality as well, but i can't figure out how to tackle it. certain models need to bind to certain events, but maybe i'm mistaken but if we delete a model from a collection it stays in memory due to these bindings to the event

Android clickable layout

一世执手 提交于 2019-11-28 23:34:36
I've got a linear layout that i have set true to be clikable + focus, But the problem is there is no focus displayed when clicked. How can i get the focus to be displayed. Heres my code <LinearLayout android:id="@+id/linear_tv_layout" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:clickable="true" android:focusable="true" android:paddingBottom="7px"> I think you need to set as background for the clickable view (the layout) a state list drawable , it's a drawable resource for which you can specify