Epicor客制化 - RowRule使用示例
生活随笔
收集整理的這篇文章主要介紹了
Epicor客制化 - RowRule使用示例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
- RowRule示例
- 1.根據行字段值對字段進行樣式設置
- 2.根據自定義方法返回值控制字段只讀
- 3.根據自定義方法返回值控制整行只讀
- 4.SettingStyle
- 5.根據自定義方法返回值執行自定義行為
- 6.RowRule失效情況
RowRule示例
1.根據行字段值對字段進行樣式設置
//高亮顯示 RowRule rr1 = new RowRule("UD103.ShortChar02", RuleCondition.Equals, "");//如果UD103.ShortChar02="" //高亮顯示該行的UD103.ShortChar02字段 rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", SettingStyle.Highlight)); ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//將RowRule添加到EpiDataView實例化對象中//自定義背景顏色 RowRule rr1 = new RowRule("UD103.ShortChar02", RuleCondition.Equals, "");//如果UD103.ShortChar02="" ControlSettings controlSettings = new ControlSettings(); controlSettings.BackColor = Color.Red;//設置自定義背景顏色 controlSettings.StyleSetName = "MyStyle001";//設置該樣式的名稱,樣式名稱不能為空,也不能使用已有樣式名,否則背景顏色將優先從該樣式名對應的樣式中獲取,導致自定義背景色無效 rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", controlSettings)); ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);2.根據自定義方法返回值控制字段只讀
private bool IsApproved(RowRuleDelegateArgs args) {string shortChar01= Convert.ToString(args.Row["ShortChar01"]);if (shortChar01== "Approved") return true;else return false; } RowRule rr1 = new RowRule(null, new RowRuleConditionDelegate2(this.IsApproved), null);//如果IsApproved方法返回true //該行的UD103.ShortChar02字段設置為只讀,控制數據輸入 rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", SettingStyle.ReadOnly)); ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//將RowRule添加到EpiDataView實例化對象中3.根據自定義方法返回值控制整行只讀
private bool IsApproved(RowRuleDelegateArgs args) {string shortChar01= Convert.ToString(args.Row["ShortChar01"]);if (shortChar01== "Approved") return true;else return false; } RowRule rr1 = new RowRule(null, new RowRuleConditionDelegate2(this.IsApproved), null);//如果IsApproved方法返回true rr1.AddAction(RuleAction.DisableRow(this.oTrans, "UD103A"));//控制整行數據輸入 ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//將RowRule添加到EpiDataView實例化對象中4.SettingStyle
除了高亮顯示和只讀樣式,還可以設置加粗,強制輸入等,具體可以查看SettingStyle枚舉:
public enum SettingStyle {Bold = 0,Error = 1,Warning = 2,OK = 3,Highlight = 4,Disabled = 5,Mandatory = 6,Invisible = 7,ReadOnly = 8 }5.根據自定義方法返回值執行自定義行為
除SettingStyle枚舉中的行為外,我們也可以自定義行為:
private bool IsApproved(RowRuleDelegateArgs args) {string shortChar01= Convert.ToString(args.Row["ShortChar01"]);if (shortChar01== "Approved") return true;else return false; } private void DoSomeThings(RowRuleDelegateArgs args){epiBt1.ReadOnly = true; } //根據IsApproved方法返回值,執行DoSomeThings方法 RowRule rr1 = new RowRule(null, new RowRuleConditionDelegate2(this.IsApproved), null, new RowRuleActionDelegate2(this.DoSomeThings),null); ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);6.RowRule失效情況
暫時發現調用了oTrans.Clear()時RowRule會失效,需改為調用oTrans.ClearDataSets()。
總結
以上是生活随笔為你收集整理的Epicor客制化 - RowRule使用示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 全息成像与集成成像原理
- 下一篇: Gmail中基本html