我有一个简单的用户控件,其中有一个文本框和标签。当我以另一种形式使用用户控件时,我创建了公共属性来访问文本框中的文本。Windows窗体应用程序中的用户控件
我的问题是,当我在窗体中调用它时,属性返回空值。我错过了什么?
我的属性如下::
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public string rtnTxtMake
{
get
{
return txtMake.Text;
}
set
{
txtMake.Text = value;
}
}
}
,并在接下来的形式按钮单击事件我所说的属性,如下所示
UserControl1 Usc = new UserControl1();
string Make = Usc.rtnTxtMake;
MessageBox.Show(Make)
你曾经设置过'txtMake.Text'吗? – Nifle 2010-01-10 08:29:00
当我运行application.is时,我在文本框中输入值不够? – Kishore 2010-01-10 08:32:27
手动当我分配txtMake.Text一些value.i'm能够得到所需的输出。但我如何分配在运行时键入的值txtMake.Text ???????? – Kishore 2010-01-10 08:38:50