private void AddRankBtn_Click(object sender, EventArgs e) { using (Kadr.UI.Common.PropertyGridDialogAdding<EmployeeRank> dlg = new Kadr.UI.Common.PropertyGridDialogAdding<EmployeeRank>()) { dlg.ObjectList = KadrController.Instance.Model.EmployeeRanks; dlg.BindingSource = employeeRankBindingSource; dlg.UseInternalCommandManager = true; dlg.InitializeNewObject = (x) => { EducDocument educDocument = new EducDocument(); EducDocumentType docType = Kadr.Controllers.KadrController.Instance.Model.EducDocumentTypes.Where(educDocType => educDocType.id == 2).First(); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<EducDocument, EducDocumentType>(educDocument, "EducDocumentType", docType, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<EmployeeRank, Rank>(x, "Rank", NullRank.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<EmployeeRank, Employee>(x, "Employee", Employee, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<EmployeeRank, EducDocument>(x, "EducDocument", educDocument, null), this); }; dlg.UpdateObjectList = () => { dlg.ObjectList = KadrController.Instance.Model.EmployeeRanks; }; dlg.ShowDialog(); } }