I am working on something fairly simple, well I thought it would be. What I want is when button1 is clicked I want it to disable button1 and enable button2. I get the error below: Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
private readonly Process proc = new Process();
public Form1()
{
InitializeComponent();
button2.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
proc.StartInfo = new ProcessStartInfo {
FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) + "/explorer.exe",
Arguments = @"D:\",
UseShellExecute = false
};
proc.Start();
button1.Enabled = false;
button2.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
proc.Kill();
button1.Enabled = true;
button2.Enabled = false;
}
To disable a button using only JavaScript you need to set its disabled property to false . For example: element. disabled = true . And to enable a button we would do the opposite by setting the disabled JavaScript property to false .
By default a button's state is enabled in HTML so by setting disabled = true, we have disabled the button for the user. 3. Then we add an event handler (addEventListener) to the input field with the event property change which monitors the interaction with elements.
The disabled attribute is a boolean attribute. When present, it specifies that the button should be disabled. A disabled button is unusable and un-clickable. The disabled attribute can be set to keep a user from clicking on the button until some other condition has been met (like selecting a checkbox, etc.).
But how to do this? You could make a method like public void SetButton1Enabled(bool enabled) { button1. Enabled = enabled; } inside Form1 and call that inside the button2_Click method of Form2 ( Form2 needs a reference to the Form1 object it was called from). Or work with events/delegates.
In your button1_click function you are using '==' for button2.Enabled == true;
This should be button2.Enabled = true;
This is now IsEnabled
takePicturebutton.IsEnabled = false; // true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With