Bassicly im creating a program that allows the user to enter values and if the values exceed a certain amount then disable a button that was on a different form. But im unsure how to access its buttons control. I thought it would be something like this? Thanx
if(value>120)
{
Form3 form3 = new Form3();
Button.Disable();
this.close();
}
Your request is to disable a button that was on another form – from reading that I assume the form already exists. By creating a new instance:
You’re creating a new instance of
Form3so you’ll never disable a button on a form that was already visible.You’ll have to make the current form aware of the instance of
Form3to be able to change anything there. Here are a few ways to make them interact:Form3upon creating orShow()ing “this” formAlso keep in mind having multiple related forms active at the same time may confuse your end-user.