c# - Handling Button Clicks from a different Class -
I have a form with a button button.
And I have a class that takes a button through it, the constructor then manages its events:
public class handling class {//. ...... go to the button; Public Handling Class (Button BTN) {this.go = BTN; This.go.Click + = new event heredollar (this.go_Click); } // .. Public Zero go_Click (Object Sender, EventArgs E) {// logic here}
What I'm doing is wrong, and why not the event is being lifted when I Press the button in the caller form?
This code works for me
public class handling class {Go to the button; Public HandlingClass (Button BTN) {go = btn; Go.Click + = go_Click; } Zero go_Click (object sender, RoutedEventArgs e) {new NotImplementedException throw); }}
and you just add the code below button in your loaded event
zero MainWindow_Loaded (Object Sender, RoutedEventArgs e) { HandlingClass HC = New HandlingClass (** Mibutan **); }
MyButton should reference your button.
Comments
Post a Comment