dynamics ax form 中所显示的 grid,可以精细控制 行、列、单元格颜色
首先要在 form 中的 datasource 中重载 displayoption方法。
1:控制行的颜色
public void displayOption(Common _record, FormRowDisplayOption _options)
{
PushTbBOMConfiguration config;
config = _record;
if (config.Color=='Red')
{
_options.textColor(WinAPI::RGB2int(255,0,0));
}
super(_record, _options);
}
效果图:
2:控制列的颜色
public void displayOption(Common _record, FormRowDisplayOption _options)
{
PushTbBOMConfiguration config;
config = _record;
// PushTbBOMConfiguration_Size02 为表格中的某一个列
PushTbBOMConfiguration_Size02.colorScheme(FormColorScheme::RGB);
PushTbBOMConfiguration_Size02.foregroundColor(WinAPI::RGB2int(255,0,0));
_options.affectedElementsByField(fieldnum(PushTbBOMConfiguration,size02));
super(_record, _options);
}
效果图:
3:控制单元格的颜色
public void displayOption(Common _record, FormRowDisplayOption _options)
{
PushTbBOMConfiguration config;
config = _record;
// PushTbBOMConfiguration_Size02 为表格中的某一个列
if (config.Color=='Red')
{
_options.affectedElementsByControl(PushTbBOMConfiguration_Size02.id());
_options.textColor(WinAPI::RGB2int(255,0,0));
}
super(_record, _options);
}
效果图: