Live Chat Icon For mobile
Live Chat Icon

How do I force the changes in base class fields to be serialized via a base class property in the inherited type’s designer?

Platform: WinForms| Category: Serialization

Sometimes you might want to let the designer serializer serialize the changes in base fields via a property rather than the field itself using the AccesssedThroughProperty attribute as follows:


public class MyBaseForm : Form
{
	[AccessedThroughProperty('MyList')]
	private ArrayList myList;
	
	public ArrayList MyList
	{
		return this.myList;
	}
}

Then when the above form is inherited and items get added to the inherited form’s designer, code will be added as follows in the inherited form’s InitializeComponent:


private void InitializeComponent()
{
	... ... ... ...
	this.MyList.Add(aNewItem);
	... ... ... ...
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.