Hi,
I am interested in using a "base" user control for building my various usercontrols for editing each entity. I would like to have some basic functionality code in the "base" to manage operations related to Data Navigation and Adding/Saving, etc. Because I need to be able to fully access the visual controls since each derived uc will look unique, I am not including those visual (form) items in my base uc, but need to reference them (for instance, to enable/disable buttons or respond to "onclicks", etc. I figured that to get around this, I would just pass my form controls from the derived uc to the base through exposed properties. This works fine for form controls, but I am also interested in dealing directly with the EntityList of the main business object being edited on the derived uc, and can't seem to figure out how to format the property in base to accept an EntityList<>, which could be of whatever type.
What I have thought of is to make the base property just an "object", since the dervied uc will define what the actual entity list is, but I am having a hard time accessing properties for the EntityList/object in the base uc code. When I write "mListMainEntity.Count", the compiler won't allow it, since .Count is not defined for generic objects. This is also not allowed: "mListMainEntity["Count"]".
Here is some example code:
derived uc :
private void HouseholdsBusinesses_Load(object sender, EventArgs e) { base.InitalizePM(); base.OtherIntitalizing(); ConfigureBindingSources(); LoadData();
//Initialize Base Property Values base.mCBM = this.dataCBM; base.mListMainEntity= mListMainEntity; base.mMainBindingSource = this.bsMainEntity; base.MainEntityType = typeof(HouseholdBusiness); }
|
base uc:
protected object mListMainEntity;
protected object MainEntityList { get { return mListMainEntity; } set { mListMainEntity = value; } }
private void MainEntityListChanged(object sender, System.ComponentModel.ListChangedEventArgs e) { if (mListMainEntity == null || mListMainEntity.Count == 0) <---This is the problem area { SetDNRemoveFalse(); } else { SetDNRemoveTrue();
if (!mPersMgr.HasChanges()) { //Disable Save/Reset Buttons SetDNEndEditFalse(); SetDNCancelEditFalse(); } else { //Enable Save/Reset Buttons SetDNEndEditTrue(); SetDNCancelEditTrue(); } } }
|
Is there some syntax I am missing? Am I going about this the wrong way?
Thanks,
Heather