【发布时间】:2012-10-12 21:46:17
【问题描述】:
今天我记一个问题,在c# winform程序中。
如果有Form A和Form B;表格B有一个文本框(需要只读)
Form A 代码如下:
B b = new B("FormB");
b.Show();
FormB 代码如下:
情况1:
public B(string str)
{
this.textbox1.text = str;
this.textbox1.Enable = false;
}
我将程序部署到客户服务器,但textbox1.text = "" 没有任何价值,但它可以在我的本地计算机上运行。
我试试这个:
情况2:
public B(string str)
{
this.textbox1.text = str;
this.textbox1.ReadOnly = true;
}
然后texbox1.text = "FormB"; 它可以在我的本地计算机和客户服务器上运行。
关键和重要的问题是,为什么situation1可以在我的本地计算机上运行,而不能在客户服务器上运行?
谁能告诉我这是为什么?
【问题讨论】:
-
在哪里初始化了 formB 的对象
-
public B(string str) { InitializeComponent(); this.textbox1.text=str; this.textbox1.Enable=false; }