/// <summary> /// Disable or enable the controls based on the change policy /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void dnNav_ChangePolicyModified(object sender, ChangePolicyEventArgs e) { if(pnlData.Enabled != e.AllowEdits || (e.AllowEdits == false && e.AllowAdditions == true)) { pnlData.Enabled = e.AllowEdits; // Allow or disallow additions based on the edit policy dnNav.AllowAdditions = e.AllowEdits; } }
/// <summary> /// This raises the <see cref="ChangePolicyModified"/> event for the control and calls the /// <see cref="TemplateControl.ChangePolicyModified"> TemplateControl.ChangePolicyModified</see> method /// in all initialized rows in the control including any header and footer templates. /// </summary> /// <param name="e">The event arguments</param> protected internal virtual void OnChangePolicyModified(ChangePolicyEventArgs e) { TemplateControl tc; int increment = (showSep) ? 2 : 1; // Enable or disable Add and Delete based on the policy btnAdd.Enabled = (changePolicy.AllowAdditions && listManager != null); btnDelete.Enabled = (changePolicy.AllowDeletes && listManager != null && listManager.Count > 0); var handler = ChangePolicyModified; if(handler != null) handler(this, e); // Let all templates know about the change too if(header != null) header.ChangePolicyModified(); if(footer != null) footer.ChangePolicyModified(); ControlCollection cc = pnlRows.Controls; for(int idx = 0; idx < cc.Count; idx += increment) { tc = (TemplateControl)cc[idx]; if(tc.IsInitialized && !tc.IsNewRowInternal) tc.ChangePolicyModified(); } }
/// <summary> /// This raises the <see cref="ChangePolicyModified"/> event for the control /// </summary> /// <param name="e">The event arguments</param> protected internal virtual void OnChangePolicyModified(ChangePolicyEventArgs e) { // Enable or disable Add and Delete based on the policy btnAdd.Enabled = (changePolicy.AllowAdditions && listManager != null); btnDelete.Enabled = (changePolicy.AllowDeletes && listManager != null && listManager.Count > 0); var handler = ChangePolicyModified; if(handler != null) handler(this, e); }