答:
窗体A(父)中打开了窗体B(子),当关闭窗体B时希望刷新窗体A,如何实现呢?
答:
目前有以下两个方案可以实现:
方案1: 在窗体B的表单插件里响应BeforeClosed事件。
Python代码:
import clr clr.AddReference("System") clr.AddReference("System.Core") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.DataEntity") clr.AddReference("Kingdee.BOS.Contracts") from Kingdee.BOS import * from Kingdee.BOS.JSON import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Const import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.List import * from Kingdee.BOS.Core.Permission import * from System import * from System.Collections.Generic import * from System.Linq import * def BeforeClosed(e): if this.View.ParentFormView != None: this.View.ParentFormView.Refresh(); this.View.SendAynDynamicFormAction(this.View.ParentFormView);
C#代码:
public override void BeforeClosed(BeforeClosedEventArgs e) { base.BeforeClosed(e); if (this.View.ParentFormView != null) { this.View.ParentFormView.Refresh(); this.View.SendAynDynamicFormAction(this.View.ParentFormView); } }
方案2: 在窗体A打开表单ShowForm回调函数里刷新
Python代码:
clr.AddReference("System") clr.AddReference("System.Core") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.DataEntity") clr.AddReference("Kingdee.BOS.Contracts") from Kingdee.BOS import * from Kingdee.BOS.JSON import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Const import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.List import * from Kingdee.BOS.Core.Permission import * from System import * from System.Collections.Generic import * from System.Linq import * def BarItemClick(e): if e.BarItemKey.lower() == "btntest": showParam = ListShowParameter();#打开列表 showParam.Context = this.Context; showParam.FormId = "PRD_MO"; showParam.PermissionItemId =PermissionConst.View; showParam.OpenStyle.ShowType = ShowType.Modal; showParam.PageId = Guid.NewGuid().ToString(); showParam.ParentPageId = this.View.PageId; this.View.ShowForm(showParam,lambda results: this.View.Refresh());
C#代码(片段):
this.View.ShowForm(showParam, new Action<FormResult>((results) => { this.View.Refresh(); }));
方案1可以实现在窗体B里不同事件里随时刷新父窗体A,但要先判断父窗体是否存在。
方案2回调函数仅当窗体关闭才执行。
切记之间的区别。
发表评论
您必须登录后才可以发布评论。