Reputation: 3850
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;
.
.
.
and I added
this.EntryTypeChanged += new
System.ComponentModel.PropertyChangedEventHandler(this.EntryType_Changed);
inside InitializeComponent
method..
Now when I open the Designer
I clicked Ignore and Continue
, it worked fine..
Now when I close and open the solution again, the eventHandler code I put in the InitializeComponent
is missing..
What is the problem?
Upvotes: 0
Views: 509
Reputation: 109080
Look at this:
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
There's the answer. Put your code in the constructor, below InitializeComponent();
.
Upvotes: 1