【发布时间】:2014-05-26 12:21:00
【问题描述】:
我有一个用户控件,上面有很多文本框。我将此用户控件添加到不同的项目中,当我在 UserControl 上编写每个属性时,我可以使用它。我想使用一个类来设置这个用户控件的文本框字段。这些是我的代码:
类:
namespace IEUserControl
{
public class IEValue
{
public string IsEmriNo { get; set; }
public string Nevi { get; set; }
public string BrutKg { get; set; }
public string NetKg { get; set; }
}
}
用户控制:
namespace IsEmriUserControl
{
public partial class UC_IsEmri : UserControl
{
public UC_IsEmri()
{
InitializeComponent();
}
//private IsEmriValue _isEmri;
//public IsEmriValue isEmri
//{
// get
// {
// return _isEmri;
// }
// set
// {
// _isEmri = value;
// }
//}
public string IsEmriNo
{
get { return txtIsEmriNo.Text; }
set { txtIsEmriNo.Text = value; }
}
public string Nevi
{
get { return txtNevi.Text; }
set { txtNevi.Text = value; }
}
public string BrutKg
{
get { return txtBrutKg.Text; }
set { txtBrutKg.Text = value; }
}
public string NetKg
{
get { return txtNetKg.Text; }
set { txtNetKg.Text = value; }
}
}
}
当我使用属性时,我可以设置文本框的值。但是我想用我的类设置我的文本框值。谁能给我一个使用类设置文本框值的示例?谢谢。
【问题讨论】:
-
你想把文本框的值赋给 IEValue 类属性吗?
-
谢谢,我的问题是 Sinatr 的回答。
标签: c# class user-controls