改变Dbgrid的选定色

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;

    Field: TField; State: TGridDrawState);

    begin

      if gdSelected in state then

      SetBkColor(dbgrid1.canvas.handle,clgreen)

      else

      setbkcolor(dbgrid1.canvas.handle,clwhite);

      dbgrid1.Canvas.TextRect(rect,0,0,field.AsString);

      dbgrid1.Canvas.Textout(rect.Left,rect.Top,field.AsString);

    end;

你可能感兴趣的:(grid)