Поиск блогу

суббота, 21 мая 2011 г.

Смена атрибутов контрола из скрипта. На примере атрибута ReadOnly

Данный скрипт полезен в тех случаях, когда, например, измененное значение одного контрола влияет на доступность другого.

using System;
using System.Windows.Forms;
using DocsVision.Platform.ObjectManager;
using DocsVision.BackOffice.View.WinForms;
using DocsVision.BackOffice.Model;
using DocsVision.BackOffice.Model.Layouts.DataAccess;
using DocsVision.BackOffice.Model.Base.Entities;
using DocsVision.BackOffice.Model.CardProperties.Entities;
using DocsVision.BackOffice.Model.Layouts.Entities;
using DocsVision.BackOffice.Model.RoleModel.DataAccess;
using DocsVision.BackOffice.Model.RoleModel.Entities;
using DocsVision.BackOffice.View.WinForms.Helpers;

private void cardControl_AfterActivate(System.Object sender, System.EventArgs e)
    {
  CardProperty prop = GetCardProperty("имя контрола");
  CardPropertyDescription.LayoutAttributeSet attrSet = prop.Description.GetLayoutAttributes(CardControl.DomainObject.SelectedLayoutId);
        attrSet.ReadOnly = true;
        PropertyController.Refresh();
    }

//Поиск контрола с нужным именем  
private CardProperty GetCardProperty(string propertyName)
 {
 foreach (CardProperty property in PropertyController.CardProperties)
  {
  if (property.Name == propertyName)
  return property;
  }
 return null;
 }

1 коммент.:

Anton Volkov комментирует...

NB! Стоит отметить, что данный скрипт меняет атрибут в настройках типа карточки, а не только в конкретном ее экземпляре.

Отправить комментарий