我创建了一个组合控件,后台无法更改其属性值,请问是什么原因?
//控件代码
public partial class desk : UserControl
{
private string number = "0";
private string name = "桌子";
private string summoney = "金额";
private string bz = "备注";
private string zt = "";
System.Drawing.Color pb1 = System.Drawing.Color.LimeGreen;
System.Drawing.Color lb5bj = System.Drawing.Color.LightGray;
System.Drawing.Color nameforecolor = System.Drawing.Color.Black;
System.Drawing.Color smoncolor = System.Drawing.Color.Red;
public desk()
{
InitializeComponent();
this.NotifyPropertyChanged(Summoney);
}
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
var propertyChanged = this.PropertyChanged;
if (propertyChanged != null)
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
[Description("属性描述"), Category("属性卡名称"), DefaultValue("属性默认值")]
public string Roomid
{
set { number = value; }
get { return number; }
}
public string Roomname
{
get { return name; }
set { name = value; }
}
public string Summoney
{
get { return summoney; }
set { summoney = value; }
}
public Color getpb1
{
get { return pb1; }
set { pb1 = value; }
}
public Color Lab5bj
{
get { return lb5bj; }
set { lb5bj = value; }
}
public string Bz
{
get { return bz; }
set { bz = value; }
}
public string Zt
{
get { return zt; }
set { zt = value; }
}
public Color SmonColor
{
get { return smoncolor; }
set { smoncolor = value; }
}
public Color NameForeColor
{
get { return nameforecolor; }
set { nameforecolor = value; }
}
public event EventHandler AX;
public delegate void select_Handle(object sender, EventArgs e, string orther);
public event select_Handle Desk_click;
private void desk_Load(object sender, EventArgs e)
{
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
UpdateStyles();
label4.Text = Roomid;//默认桌号
label1.Text = Roomname;//默认名称
label1.ForeColor = NameForeColor;//默认名称背景色
label2.Text = Summoney;//金额
label2.ForeColor = SmonColor;//金额背景色
label3.Text = Bz;//备注
label5.Text = Zt;//状态
this.panel1.BackColor = getpb1;//默认顶部颜色
this.label5.BackColor = Lab5bj;//默认背景颜色
}
private void desk_MouseClick(object sender, MouseEventArgs e)
{
//if (AX != null)
//{
// AX(this, new EventArgs(),"");
//}
}
private void desk_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
private void label4_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
private void panel1_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
private void label1_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
private void label5_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
private void label2_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
private void label3_Click(object sender, EventArgs e)
{
if (Desk_click != null)
Desk_click(this, new EventArgs(), this.Name);
}
}
//前台引用代码
private void Test_Load(object sender, EventArgs e)
{
this.desk1.Summoney = DateTime.Now.ToString("yyyy-MM-dd");
}