This question already has answers here:
How to enable button in Form 1 from Form 2 using public get set?
(5 answers)
Closed 4 years ago.
I want to disable the button from other form from current form and enable the button again after clicking reset button.
Add a public method where you control the button state as disabled or enabled in this form,then transfer this form as parameter to other form
Related
This question already has answers here:
C# - Add button click events using code
(3 answers)
Closed 3 years ago.
I very new to C# and I would like to add a Button to a form programmatically. When this button is pressed I want it to run some code (like a normal button woukd work). But, everywhere I have searched only shows how to add the button and not how to add code to the button.
One way to do it is to give the button a name property, then in your code you "refer" to the button by it's name like so:
void btnButton_Click(object sender, EventArgs e)
{
// your code goes here
}
where btnButton_Click is the name of the button.
This question already has answers here:
How do I handle click events on multiple similar buttons in WPF?
(3 answers)
Click event for button in loop C# WPF
(3 answers)
How would you know which element of an ItemsControl sends an event in MVVM?
(5 answers)
How to find out which button I pressed?
(1 answer)
Closed 5 years ago.
On WPF, if I have only one button click event shared for two or more (52 being more precise) is there a way to distinguish which button the event come from?
private void Button_Card_Click(object sender, RoutedEventArgs e)
{
// for testing
// it works for each button, but which one has been clicked?
MessageBox.Show("Clicked");
}
First button object with event set up
Second button object with event set up
sender should be the clicked button, but also look at RoutedEventArgs.Source and .OriginalSource
I would also look into using Commands and CommandParameter to indicate which was clicked.
This question already has answers here:
C#: How do you send OK or Cancel return messages of dialogs when not using buttons?
(3 answers)
Closed 6 years ago.
I Have a Form that I have opened up as a dialog. On the Form I have a cancel and a correct button, I need to get the positive feedback from the form when the user selects the correct button. How would I go about linking the correct button to the OK Dialog result?
From MSDN Button.DialogResult Property comes this answer:
private void InitializeMyButton()
{
// Create and initialize a Button.
Button button1 = new Button();
// Set the button to return a value of OK when clicked.
button1.DialogResult = DialogResult.OK;
// Add the button to the form.
Controls.Add(button1);
}
applied to your case you would just simply assign this to the property of your correct button:
correct_btn.DialogResult = DialogResult.OK;
This question already has an answer here:
Application 'Deactivate' event
(1 answer)
Closed 8 years ago.
I want to create an application that closes one of it's window when the user clicks on another application (or in other words the application loses focus or inactive). All the windows in my application to have the property TopMost = true.
How I can do that?
your help is greatly appreciated.
Edit (Update):
I need when I click on another window in my application, the window is not closed. Only when my application loses focus (the user clicks on another application), the window will be closed.
Check out the Deactivate event, or override OnDeactivate:
protected override void OnDeactivate(EventArgs e)
{
Close();
}
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
get the splitcontainer context in user control click event
I have a split container in which right panel, i have a user control on top.I have a left panel which has navigation links.now if i click a link in left side, a form opens below user control.Now if i click view button in user control, a new form should open in right side of panel below user control. also if i have some values in textboxes in form below user control, when i click save button in user cotrol, i should be able to fetch those values in user control button click event.how to do it?
You can use public properties(value of textbox.text) in you user control, they will contains your values. Also you can create static class with dictionary values, something like a session in web.