请问cxgrid怎么凸显多个筛选列表头,像excel一样,筛选一列,这列表头有个标记,多列同时筛选则多列都有一个标记
谢谢

解决方案 »

  1.   

    cxgrid course
      

  2.   

    試試設定其屬性:設置cxgrid的cxGrid1DBTableView1-->DataController-->GridMode為False;
      

  3.   

    1.如果LZ是想在cxgrid在顯示數據時就像Excel那样的过滤功能,像Excel那样高亮显示选区的行号列标(即篩選列表頭效果)2.通过它的OnDrawColumnHeader事件和OnDrawIndicatorCell事件把它变成像Excel那样以高亮显示行号列标,即可實現凸显多个筛选列表头,像excel一样,筛选一列,这列表头有个标记
      

  4.   

    我分享一下程序代碼,以供大家共同學習,互助共進1.OnDrawColumnHeader事件源码如下:procedure TfrmAccount.cxtvMasterCustomDrawColumnHeader(
      Sender: TcxGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: Boolean);
    var
        AButtonState: TcxButtonState;
        ARect: TRect;
    begin
        if AViewInfo.Column.Selected then begin
            AButtonState := cxbsHot;
            ARect := AViewInfo.Bounds;
            Sender.LookAndFeelPainter.DrawHeader(ACanvas, ARect, AViewInfo.TextAreaBounds
                , [], cxBordersAll, AButtonState, AViewInfo.Column.HeaderAlignmentHorz
                , AViewInfo.Column.HeaderAlignmentVert, False, False
                , AViewInfo.Column.Caption, ACanvas.Font, Sender.Styles.Selection.TextColor
                , Sender.Styles.Selection.Color);
            ARect.Left := ARect.Right - 19;
            ARect.Right := ARect.Right - 1;
            InflateRect(ARect, -1, -3);
            if AViewInfo.Column.Options.Filtering then begin
                Sender.LookAndFeelPainter.DrawFilterDropDownButton(ACanvas, ARect
                    , cxbsNormal, AViewInfo.Column.Filtered);
                OffsetRect(ARect, -16, 0);
            end;
            if AViewInfo.Column.SortIndex <> -1 then
                Sender.LookAndFeelPainter.DrawSortingMark(ACanvas, ARect
                    , AViewInfo.Column.SortOrder=soAscending);
            ADone := true;
        end;
    end; 
      

  5.   

    2.OnDrawIndicatorCell事件源码如下:procedure TfrmAccount.cxtvMasterCustomDrawIndicatorCell(
      Sender: TcxGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
    var
        AButtonState: TcxButtonState;
        clFont, clBrush: TColor;
    begin
        if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then Exit;    if TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Selected then begin
            AButtonState := cxbsHot;
            if Sender.LookAndFeelPainter.LookAndFeelStyle = lfsOffice11 then begin
                clFont := ACanvas.Font.Color;
                clBrush := ACanvas.Brush.Color;
            end else begin
                clFont := Sender.Styles.Selection.TextColor;
                clBrush := Sender.Styles.Selection.Color;
            end;
        end else begin
            AButtonState := cxbsNormal;
            clFont := ACanvas.Font.Color;
            clBrush := ACanvas.Brush.Color;
        end;
        Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
            AViewInfo.ContentBounds, [], [bLeft, bRight, bBottom], AButtonState, taCenter
            , vaCenter, False, False, IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1)
            , ACanvas.Font, clFont, clBrush);
        ADone := True;
    end;