cxGrid에서 Cell의 색을 변경하기.

cxGrid의 TableView의 이벤트에서 CustomDrawCell 이벤트가 있습니다.
이 이벤트는 AViewInfo: TcxGridTableDataCellViewInfo의 값을 이용해서 작업이 가능합니다.
퀀텀은 클래스 객체로 연결 되어 있으므로 AViewInfo: TcxGridTableDataCellViewInfo를 이용해서 셀의 색상 및 레코드의색상을 변경 가능 합니다.

AViewInfo.GridRecord.Values[  Visible Column Index ]를 이용하면 됩니다.

Visible Column Index 는 컬럼 Move옵션이 ture인경우 수시로 변하기 때문에 아래처럼 구하시면 됩니다.
cxGridDBTableView( Sender ).GetColumnByFieldName(‘필드명’).VisibleIndex

코딩은 아래처럼 하시면 됩니다.

procedure TForm2.cxGrid1DBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
Var
Inx : Integer;
begin
Inx := cxGridDBTableView( Sender ).GetColumnByFieldName(‘필드명’).VisibleIndex
if Copy( AViewInfo.GridRecord.Values[ Inx ] , 1 , 1 ) = ‘S’ then
ACanvas.Brush.Color := clRed;
end;

참고 하시기 바랍니다.

Author: yyjksw