开发者

resize label text in Windows application

开发者 https://www.devze.com 2023-02-16 10:06 出处:网络
how to resize lable text form2 at run time in C# windows application?.. for example if click button in form1 to open form2 then how to change form2 label textat run time...normaly 开发者_C百科form2 la

how to resize lable text form2 at run time in C# windows application?.. for example if click button in form1 to open form2 then how to change form2 label text at run time...normaly 开发者_C百科form2 label text "saran" but if you can click form1 button1 click automatically change to "SARAN" Example code:

private void button1_Click(object sender, EventArgs e)
{
    Form2 form2 = new Form2();
    form2.Show();
}


You will either have to make the modifier public of the Textbox on form2 or you will have to create a method in form2 that will change the text on the form.

Something like

Example 1: textbox modifier is public

private void button1_Click(object sender, EventArgs e)
{
    Form2 form2 = new Form2();
    form2.myTextBox.Text = "TADA";
    form2.Show();
}

Example 2: public method on form2

private void button1_Click(object sender, EventArgs e)
{
    Form2 form2 = new Form2();
    form2.SetMyTextBox("TADA");
    form2.Show();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消