最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

设置窗体网格控件中字段的背景颜色[DisplayOptionInitialize] / Set background color for a field in form grid [DisplayOptionInitialize]

网络文摘 William 196浏览 0评论
Hi Folks, Today I am going to discuss how to make a filed text/background colorful :) This could be really helpful if you want to set such color based on an enum, like the status of the record or some kind of color coding on the grid based on an enum value. You can apply color on the entire grid line or one/more specific fields on the grid. So let's get started. First, let's see how to achieve this using event handler. Assume there is field 'onHold' and you want to set vendor account no background/text to red or green based on this.  Go to your 'VendTable' form and vendTable data source and copy the event handler names 'DisplayOptionInitialize'. Paste this in a new class and write below code under this method (once you paste the event handler). <CodeSample> On new forms, the same can be achieved using overriding 'DisplayOption' method on the data source. Below code will give a hint public void displayOption(Common _record, FormRowDisplayOption _options)         {             VendTable    vendTable = _record;           //  _options.affectedElementsByField(<FieldName>);             //    _options.backColor(<Color>);             super(_record, _options);         } Please note, the color thing doesn't work when the user selects a record, it will make the selected line in default color setting. But useful when opening a grid and see the entire set of records.  See more.. Table Event handler methods in Dynamics 365 FO Form Event handler methods in Dynamics 365 FO Cheers!!! -Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址