1、当表单打开时,在哪些事件中设置控件的可用性、可见性有效果
A、添加以下控件及字段
B、代码设置示例:
public override void OnInitialize(InitializeEventArgs e)
{
base.OnInitialize(e);
this.View.GetControl<Button>("F_ZYF_Button").Enabled = false;
this.View.GetControl<Button>("F_ZYF_Button5").Visible = false;
this.View.Model.SetValue("F_ZYF_Text", "F_ZYF_Text");
}
public override void OnBillInitialize(BillInitializeEventArgs e)
{
base.OnBillInitialize(e);
this.View.GetControl<Button>("F_ZYF_Button1").Enabled = false;
this.View.GetControl<Button>("F_ZYF_Button6").Visible = false;
this.View.Model.SetValue("F_ZYF_Text1", "F_ZYF_Text1");
}
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.View.GetControl<Button>("F_ZYF_Button2").Enabled = false;
this.View.GetControl<Button>("F_ZYF_Button7").Visible = false;
this.View.Model.SetValue("F_ZYF_Text2", "F_ZYF_Text2");
}
public override void BeforeBindData(EventArgs e)
{
base.BeforeBindData(e);
this.View.GetControl<Button>("F_ZYF_Button3").Enabled = false;
this.View.GetControl<Button>("F_ZYF_Button8").Visible = false;
this.View.Model.SetValue("F_ZYF_Text3", "F_ZYF_Text3");
}
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
this.View.GetControl<Button>("F_ZYF_Button4").Enabled = false;
this.View.GetControl<Button>("F_ZYF_Button9").Visible = false;
this.View.Model.SetValue("F_ZYF_Text4", "F_ZYF_Text4");
}
C、效果:
2、this.View.UpdateView()的使用
this.View.UpdateView()要在单据完全加载完成后使用
带参的可在OnLoad、BeforeBindData、AfterBindData使用
public override void OnInitialize(InitializeEventArgs e)
{
base.OnInitialize(e);
//不能使用this.View.UpdateView();//会死循环
}
public override void OnBillInitialize(BillInitializeEventArgs e)
{
base.OnBillInitialize(e);
//不能使用this.View.UpdateView(); //报错
}
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//不能使用this.View.UpdateView();//会死循环
//可使用this.View.UpdateView("参数");
}
public override void BeforeBindData(EventArgs e)
{
base.BeforeBindData(e);
//不能使用this.View.UpdateView();//会死循环
//可使用this.View.UpdateView("参数");
}
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
//不能使用this.View.UpdateView();//会死循环
//可使用this.View.UpdateView("参数");
}
推荐阅读