eventhandler

DataGridView: 'cannot convert from method group to keys

六月ゝ 毕业季﹏ 提交于 2019-12-12 05:37:11
问题 I have a WinFormApp with a datagridview and I'm trying to write a method which does something when you press enter on the selected row. For example - the gridview displays some data from my database and it has 4 columns, after you finish editing those columns the way you like, you press enter and the data will be saved in the database with the new values. Currently I have this in my Form1() dataGridView1.PreviewKeyDown += new PreviewKeyDownEventArgs(dataGridView1_PreviewKeyDown); which I dont

Click event not firing for custom UserControl on a form

心已入冬 提交于 2019-12-12 01:31:17
问题 I have created a UserControl called Toggle , this is my code for it [DefaultEvent("Click")] public partial class Toggle : UserControl { public bool ToggleStatus { get { return toggleStatus; } } private bool toggleStatus { get; set; } public Toggle() { InitializeComponent(); toggleStatus = true; } private void toggleClick(object sender, EventArgs e) { if (toggleStatus) { // currently set as "true" or "on" this.lblSwitch.Dock = DockStyle.Right; this.pnlBackground.BackColor = System.Drawing

How to Trigger Click Event of a Button in UserControl from ContentPage?

为君一笑 提交于 2019-12-11 21:21:25
问题 I have a ShoppingCart UserControl on MasterPage . I have a following functionality: User adds item to the cart. after clicking the button " Complete Sale " in UserControl the page is redirected to " CustomerInfo.aspx " and after filling the Customer information and clicking on submit which is on CustomerInfo.aspx page i want to call the " Complete Sale " click event of UserControl from " Customerinfo.aspx " page. Customerinfo.aspx.cs protected void btnSubmit_Click(object sender, EventArgs e)

How can I extract the “real” target from an Event Handler that was defined anonymously?

我只是一个虾纸丫 提交于 2019-12-11 10:47:50
问题 Follow up to my question here: According to a comment made - The compiler creates a class member with a fictitious name and attaches it just as you would attach a declared method. I do not fully comprehend what this means but I can verify that if instead of saying Foo.Bar += (S, E) => { /*Code Goes Here*/ } I instead say Foo.Bar += FooBar; private void FooBar( object sender, EventArgs e ){ /*Code Goes Here*/ } then Event.Target changes from WhatIsThis.App.<>c to WhatIsThis.App . That's

set button on action within method java

爱⌒轻易说出口 提交于 2019-12-11 08:51:07
问题 How could I set the action of a button within the same method I am creating the buttons? My desired method would be something like this: private void buttonsCreation() { //----------------creation of interactive buttons with text----------------- Button buttonForLoad = new Button("Load footage file"); Button buttonForSave = new Button("Save footage file"); Button buttonForSaveAs = new Button("Save as footage file"); ButtonbuttonForRun = new Button("Run footage animation"); Button

c# Adding a listener to Event with only the method name (text)

泄露秘密 提交于 2019-12-10 22:58:18
问题 I am trying to use Reflection to add a method from a class to an event. Here is my setup. Have a class with a keyPressDown & keyPressUp method. I also have an Event in this class. keyPressDown & keyPressUp will fire whatever methods are subscribed to it (if any). These additional methods are controlling RGB light emitting diodes. One method can flash a color, another can fade a color, etc.. I can subscribe to the event like myEventKeyUp += myClass.MethodA; My problem is, I am storing the

Why is my event handlers target <>c? Also - What even is <>c?

折月煮酒 提交于 2019-12-07 15:34:16
问题 Following the specifications for creating a Minimal, Complete and Verifiable code set, please see below : using System; using System.Data; using System.Linq; using System.Windows; namespace WhatIsThis{ /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { private void Application_Startup( object sender, StartupEventArgs e ) { Foo.Bar += ( S, E ) => Console.WriteLine( "Do Something!" ); } protected override void OnActivated( EventArgs e ) {

Event handler handling events out of order

孤者浪人 提交于 2019-12-06 11:37:32
问题 I'm doing some work with a radio microcontroller (BLE). The mechanism supported in .NET's GenericAttributeProfile namespace, is to use an EventHandler whenever new data comes in (notifications). A problem I'm currently seeing is that, despite my data being sent in order from the radio hardware, the data does not necessarily get dealt with in that order. I'm guessing this is due to the asynchronous manner in which the EventHandler is invoked (please correct me if I'm wrong). Every time a new

JavaFX EventHandler pass parameter

喜夏-厌秋 提交于 2019-12-06 07:03:21
问题 Rectangle rect1 = new Rectangle(10, 10, 20, 20); Rectangle rect2 = new Rectangle(60, 10, 20, 20); EventHandler<MouseEvent> event = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent ae) { System.out.println("aaa"); } }; rect1.setOnMouseClicked(event); rect2.setOnMouseClicked(event); How to click rect1 print aaa, click rect2 print bbb ? In my real program, I have hundreds of rectangles, and in the event, I have many things to do. So I don't want declare event for every

JavaFX ContextMenu how do I get the clicked Object?

∥☆過路亽.° 提交于 2019-12-05 18:07:02
I am learning javafx.scene.control.ContextMenu, and right now I am facing a problem: how do I get the clicked Object from EventHandler? both event.source() and event.target() return the MenuItem. let me explain with an example: what should I write inside the function handle? TextField text = new TextField(); Label label1 = new Label("hello"); Label label2 = new Label("world"); Label label3 = new Label("java"); ContextMenu menu = new ContextMenu(); MenuItem item = new MenuItem("copy to text field"); menu.getItems().add(item); item.setOnAction(new EventHandler(){ public void handle(Event event)