public partial class FrmEditSiteParticulars : Form, INotifyPropertyChanged
{
public enum EntryTypes
{
Undefined,
Site,
Particular
}
private EntryTypes _EntryType;
private EntryTypes EntryType {
get{return _EntryType;}
set
{
if (value != _EntryType)
{
_EntryType = value;
OnPropertyChanged("EntryType");
}
}
}
public event PropertyChangedEventHandler EntryTypeChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = EntryTypeChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
.
.
.
public event PropertyChangedEventHandler PropertyChanged;
.
.
.
我加了
this.EntryTypeChanged += new
System.ComponentModel.PropertyChangedEventHandler(this.EntryType_Changed);
在InitializeComponent
方法内..
现在,当我打开设计师
我点击Ignore and Continue
,效果很好..
现在当我再次关闭并打开解决方案时,我放在InitializeComponent
中的eventHandler代码丢失了..
有什么问题?
答案 0 :(得分:1)
看看这个:
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
答案是肯定的。将代码放在InitializeComponent();
下面的构造函数中。