开发者

resize label text in Windows application

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜