Epicor客制化 - RowRule使用示例
生活随笔
收集整理的這篇文章主要介紹了
Epicor客制化 - RowRule使用示例
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
目錄
- RowRule示例
- 1.根據(jù)行字段值對(duì)字段進(jìn)行樣式設(shè)置
- 2.根據(jù)自定義方法返回值控制字段只讀
- 3.根據(jù)自定義方法返回值控制整行只讀
- 4.SettingStyle
- 5.根據(jù)自定義方法返回值執(zhí)行自定義行為
- 6.RowRule失效情況
RowRule示例
1.根據(jù)行字段值對(duì)字段進(jìn)行樣式設(shè)置
//高亮顯示 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實(shí)例化對(duì)象中//自定義背景顏色 RowRule rr1 = new RowRule("UD103.ShortChar02", RuleCondition.Equals, "");//如果UD103.ShortChar02="" ControlSettings controlSettings = new ControlSettings(); controlSettings.BackColor = Color.Red;//設(shè)置自定義背景顏色 controlSettings.StyleSetName = "MyStyle001";//設(shè)置該樣式的名稱,樣式名稱不能為空,也不能使用已有樣式名,否則背景顏色將優(yōu)先從該樣式名對(duì)應(yīng)的樣式中獲取,導(dǎo)致自定義背景色無(wú)效 rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", controlSettings)); ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);2.根據(jù)自定義方法返回值控制字段只讀
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字段設(shè)置為只讀,控制數(shù)據(jù)輸入 rr1.AddAction(RuleAction.AddControlSettings(this.oTrans, "UD103.ShortChar02", SettingStyle.ReadOnly)); ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//將RowRule添加到EpiDataView實(shí)例化對(duì)象中3.根據(jù)自定義方法返回值控制整行只讀
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"));//控制整行數(shù)據(jù)輸入 ((EpiDataView)(this.oTrans.EpiDataViews["UD103"])).AddRowRule(rr1);//將RowRule添加到EpiDataView實(shí)例化對(duì)象中4.SettingStyle
除了高亮顯示和只讀樣式,還可以設(shè)置加粗,強(qiáng)制輸入等,具體可以查看SettingStyle枚舉:
public enum SettingStyle {Bold = 0,Error = 1,Warning = 2,OK = 3,Highlight = 4,Disabled = 5,Mandatory = 6,Invisible = 7,ReadOnly = 8 }5.根據(jù)自定義方法返回值執(zhí)行自定義行為
除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; } //根據(jù)IsApproved方法返回值,執(zhí)行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失效情況
暫時(shí)發(fā)現(xiàn)調(diào)用了oTrans.Clear()時(shí)RowRule會(huì)失效,需改為調(diào)用oTrans.ClearDataSets()。
總結(jié)
以上是生活随笔為你收集整理的Epicor客制化 - RowRule使用示例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 全息成像与集成成像原理
- 下一篇: Gmail中基本html