I've been trying to use a button to extend the size of my form. However, for some reason, it won't let me do this. I'd think this would be an easy thing to accomplish, but I get the error:
"An object reference is required for the non-static field, method, or property 'System.Windows.Forms.Control.Width.get'
The code I'm using that causes that error is
private void options_Click(object sender, EventArgs e)
{
FileSortForm.Height = 470;
}
FileSortForm is the name of my Form. Also, from the advice of another site, I added this code into the Form Load code.
this.Size = new System.Drawing.Size(693, 603);
You need to change the height of a specific instance of your form. Most likely in your case this
will be the instance you want to modify:
private void options_Click(object sender, EventArgs e)
{
this.Height = 470;
}
It seems that FileSortForm
is the name of your class, not your form instance. If this is the case, you can simply write
private void options_Click(object sender, EventArgs e)
{
this.Height = 470; // "this" is your form instance.
}
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