How in a Delphi dxDBGrid can I change the color of a single row?

时光毁灭记忆、已成空白 提交于 2019-12-24 10:59:43

问题


Basically a client wants to change the color of a single row in a Delphi dxDBGrid. There isn't a rows property like there is columns.

Any ideas?


回答1:


You can use styles. The DevExpres Grid in DBTableView has a event named: OnGetContentStyle in Styles part.

You can create at design two styles and apply the desired style at runtime.

procedure TFormBrBase.DBTableViewStylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);

With ARecord you can access to the actual record values. With this values you decide and change the value of the AStyle(out) param. This line is painted with this style.

Greetings.


Neftalí
Germán Estévez




回答2:


Sorry, simply use the OnCustomDraw event. argh Friday mornings.




回答3:


I use on the grid's OnCustomDrawCell event, eg:

If ANode.Values[SomeColumnName.Index] = SomeValue then
  AFont.Color := clRed;

This is assuming it is the QuantumGrid v3 you're referring to. If it's v4 or later then the answer pointing you at cxStyles is correct.



来源:https://stackoverflow.com/questions/925897/how-in-a-delphi-dxdbgrid-can-i-change-the-color-of-a-single-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!