T tylhx Unregistered / Unconfirmed GUEST, unregistred user! 2003-06-02 #1 各位高手: 我如何改变DBGrid中高亮条的颜色(蓝变绿),请指教? [green][/green]
Y yzhshi Unregistered / Unconfirmed GUEST, unregistred user! 2003-06-02 #2 procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdSelected in State then dbgrid1.Canvas.Brush.Color := clGreen else dbgrid1.Canvas.Brush.Color := clWhite; dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if gdSelected in State then dbgrid1.Canvas.Brush.Color := clGreen else dbgrid1.Canvas.Brush.Color := clWhite; dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;
G gyang Unregistered / Unconfirmed GUEST, unregistred user! 2003-06-02 #3 procedure TfrmSQLMain.grdMainDrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin if gdSelected in State then //如果当前行为选中状态 begin grdMain.Canvas.Brush.Color := clNavy; //背景为蓝色 grdMain.Canvas.Font.Color := clWhite; //文字为白色 end else if DMConn.adsEdit.RecNo mod 2 = 0 then //如果是双数行 begin grdMain.Canvas.Brush.Color := $00EDDADA; //$00EDDADA也是颜色, 只是Delphi无定义成常量 grdMain.Canvas.Font.Color := clBlack; end else begin //如果是单数行 grdMain.Canvas.Brush.Color := clWhite; grdMain.Canvas.Font.Color := clBlack; end; grdMain.Canvas.FillRect(Rect); //画一个长方形的背景 grdMain.Canvas.TextOut(Rect.Left + 3, Rect.Top + 2, Field.AsString); //把文字画上去 end;
procedure TfrmSQLMain.grdMainDrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState); begin if gdSelected in State then //如果当前行为选中状态 begin grdMain.Canvas.Brush.Color := clNavy; //背景为蓝色 grdMain.Canvas.Font.Color := clWhite; //文字为白色 end else if DMConn.adsEdit.RecNo mod 2 = 0 then //如果是双数行 begin grdMain.Canvas.Brush.Color := $00EDDADA; //$00EDDADA也是颜色, 只是Delphi无定义成常量 grdMain.Canvas.Font.Color := clBlack; end else begin //如果是单数行 grdMain.Canvas.Brush.Color := clWhite; grdMain.Canvas.Font.Color := clBlack; end; grdMain.Canvas.FillRect(Rect); //画一个长方形的背景 grdMain.Canvas.TextOut(Rect.Left + 3, Rect.Top + 2, Field.AsString); //把文字画上去 end;