Variants of the block edit facility

Option 1: proactive action

If it becomes clear that the object will need to access read-only before it is opened, you can use the following example:

private void button1_Click(object sender, EventArgs e)
    { 
        ICSSoft.STORMNET.DataObject[] dObjs = objectListView1.GetObjectsByMarks();
        foreach (ICSSoft.STORMNET.DataObject d in dObjs)
        {
            //lock needed to unlock object (unlock the object with a different key will be impossible). 
            Guid key = new Guid();
            d.LockObject(key);
            OnEditEvent("", d, "");
        }
    }

In this case, the database lock will not be sent.

Option 2: the form is already open

 public override void Edit(ICSSoft.STORMNET.DataObject dataobject, string contpath, string propertyname, object tag)
        {
            if (dataobject == null)
                return;

            if (!((Квалификация)dataobject).Актуально)
            {
                this.SetEditManagerReadOnly(true);
                this.Caption += "(date)";
            }

            base.Edit(dataobject, contpath, propertyname, tag);
        }
Переведено сервисом «Яндекс.Переводчик» http://translate.yandex.ru