I'm trying to build test apps for practice. I work with forms and realised that I can't change the form appearance that already used InitializeComponent()
in C# Visual Studio App.
My code:
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.Size = new Size(50, 50);
}
Can anyone help me?
form1
is a brand new form, whose size you're setting, but which you're never showing.
All you need is:
private void button1_Click(object sender, EventArgs e)
{
this.Size = new Size(50, 50);
}
Actually, the this
is redundant, but makes it a bit clearer which form you're changing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.