private void showCategory_Load(object sender, EventArgs e)
{
string categoryId = "100"
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = categoryId;
}
如何将表单加载中的字符串categoryId
传递给按钮单击?
谢谢。
答案 0 :(得分:2)
如果是Windows Forms应用程序,而不是在类级别使用变量,而不是在函数
中public partial class showCategory : Form
{
string categoryId = null;
private void showCategory_Load(object sender, EventArgs e)
{
this.categoryId = "100";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = this.categoryId;
}
}
如果是Web应用程序 - 存储一些状态callection的值:ViewState,Session,HiddenField等等。