-3

i managed to do somehow what i want by doing this

    private void textBox1_Enter(object sender, EventArgs e)
    {
        textBox1.Text = "a1";
    }

But i want this to happen without clicking on the textbox The way i did upper required me to click before a1 will be written there.

4

2 回答 2

4

您需要在Load您的表格中执行此操作

private void YourFormName_Load(object sender, EventArgs e)
{
     string someValue="Get the value from wherever you want";
     textBox1.Text = someValue;
}
于 2012-08-27T16:07:41.633 回答
0

例如,如果您需要读取 config 的全局变量,在 appsetting

NameValueCollection appSettings = ConfigurationManager.AppSettings;
textBox1.Text = appSettings["yourkey"];
于 2012-08-27T16:03:27.343 回答