D10.DevExpress使用经验累计之一
Grid
//展开分组
grdVMain.DataController.Groups.FullExpand;
//分组改变时展开分组,FGrouping 为全局变量
procedure TfrmOrderMgr.grdVMainDataControllerGroupingChanged(
Sender: TObject);
begin
if FGrouping then Exit;
if grdVMain.DataController.Groups.GroupingItemCount = 0 then Exit;
FGrouping := true;
try
grdVMain.DataController.Groups.FullExpand;
finally
FGrouping := false;
end;
end;
//给grid上色
//dmMain.cxStyleRecNormal,dmMain.cxStyleRecCompleted为预先创建好的style
//最后将grdVMainFCompleted设为最后一列
procedure TfrmOrderMgr.grdVMainStylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
AIndex: Integer;
AVar: Variant;
ABoolean: Boolean;
begin
if grdVMainFCompleted.GroupIndex <> -1 then Exit; //分组时不分颜色
AIndex := grdVMainFCompleted.Index;
// AIndex := AIndex - grdVMain.DataController.Groups.GroupingItemCount;
AVar := ARecord.Values[AIndex];
if VarIsOrdinal(AVar) then ABoolean := AVar else ABoolean := false; //是否为bool值
if ABoolean then
AStyle := dmMain.cxStyleRecCompleted else AStyle := dmMain.cxStyleRecNormal;
end;