在delphi中怎样改变stringgrid锁定行和列的颜色

来源:百度知道 编辑:UC知道 时间:2024/06/04 19:19:29
据说锁定的行列会被系统自行颜色取代,怎么解决啊?

自己手绘

stringgrid的onDrawCell

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;

  Rect: TRect; State: TGridDrawState);

var

  r:TRect;

begin

  with StringGrid1.Canvas do

  begin

    if gdSelected in State then

      Brush.Color:=clRed

    else

      Brush.Color:=clWhite;

    FillRect(rect);

    SetRect(r,Rect.Left+2,Rect.Top+2,Rect.Right-3,Rect.Bottom-3);

    Font.Color:=clBlack;

    DrawText(Handle,PAnsiChar(StringGrid1.Cols[acol][arow]),

             -1,R,DT_CENTER or DT_WORD_ELLIPSIS);