有哪位大吓能说出这个事件的用法!
procedure TmenuFm.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
application.MessageBox('aaa','');end;
谢谢
procedure TmenuFm.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
application.MessageBox('aaa','');end;
谢谢
DataCol: Integer; Column: TColumn;State: TGridDrawState;
singlecolor:TColor;doublecolor:TColor;selectedcolor:TColor);
var
dataset:tdataset;
dbgrid:tdbgrid;
begin
dataset:=TDBGrid(Sender).DataSource.DataSet;
dbgrid:=TDBGrid(Sender);
if (dataset.Recno mod 2) <> 0 then //
begin
dbgrid.Canvas.Font.Color := clBlack;
dbgrid.Canvas.Brush.Color := singlecolor; //
dbgrid.Canvas.FillRect(Rect); //
end
else
begin
dbgrid.Canvas.Font.Color := clBlack;
dbgrid.Canvas.Brush.Color :=doublecolor;
dbgrid.Canvas.FillRect(Rect);
end; //
dbgrid.Canvas.TextRect( Rect, Rect.Left, Rect.Top, Column.Field.DisplayText);
if gdSelected in State then //
begin
dbgrid.Canvas.Font.Color := clBlack;
dbgrid.Canvas.Brush.Color :=selectedcolor;
dbgrid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
Sender:被调用Gird的自身对象.
Rect: 网格单元的矩形坐标
Field: 将会被填到这个网格的字段.
State:当前这个网格单元的壮态.(被选中网格, 固定网格等).
Rect: TRect; State: TGridDrawState);
Var
Rect1,Rect2 : TRect;
iFntHeight : Integer;
begin
if gdFixed in State then exit;
StringGrid1.RowHeights[ARow] :=60;
iFntHeight := StringGrid1.Font.Height ; Rect1.Left := Rect.Left ;
Rect1.Top := Rect.Top;
Rect1.Right := Rect.Right;
Rect1.Bottom := Rect.Top - iFntHeight +2; //Round(Rect.Top + iFntHeight);; Rect2.Left := Rect.Left ;
Rect2.Top := Rect.Top - iFntHeight +2;
Rect2.Right := Rect.Right;
Rect2.Bottom := Rect.Bottom;
if gdSelected in State then
begin
With StringGrid1.Canvas do
begin
brush.Color := clYellow;
Font.Color := clBlack;
TextRect(Rect1,Rect1.Left + 2, Rect1.Top + 2,'helooAcol,ARow]');
TextRect(Rect2,Rect2.Left + 2, Rect2.Top + 2,'good');
end;
end
Else
begin
With StringGrid1.Canvas do
begin
if ARow mod 2 = 0 then
begin
Brush.Color := clInfoBk;
end
else
begin
Brush.Color := $0073EEBA;//$00D8EDA0;
end;
Font.Color := clBlack;
FillRect (Rect);
// TextRect(Rect,Rect.Left + 2, Rect.Top + 2,StringGrid1.Cells[Acol,ARow]);
TextOut (Rect.Left+2, Rect.Top+2,StringGrid1.Cells[Acol,ARow]);
end;
end;
end;
procedure TInboxForm.dbgrdInboxDrawDataCell(Sender: TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);var
i, viWidth : integer;
OldColor : TColor;
OldStyle : TFontStyles;
begin
if tbInboxRefNo.IsNull then Exit;
With (Sender as TDBEGrid), tbInBox do
With (Sender as TDBEGrid), tbInBox do
begin
OldColor := Canvas.Font.Color;
OldStyle := Canvas.Font.Style;
i := Canvas.Font.height;field DECONSOLIDATE in the inbox is True.}
if UpperCase(Field.FieldName) = UpperCase('SenderName') then
begin
Canvas.Brush.Style := bsClear;
Canvas.TextOut((Rect.Left + viBMPWidth), (Rect.Top + 2), FieldByName('SenderName').asString);
if FieldByName('Deconsolidate').asBoolean then
begin
DrewBitmap(TDBEGrid(Sender).Canvas,
imBitmapSet.Picture.Bitmap,
BMP_RedDiamond,
Bounds((Rect.Left + 1), (Rect.Top + 2), viBMPHigh, viBMPWidth));
end;
end; if Field.FieldName = 'Details' then
for i := 0 to 3 do
MyTextOut( Sender, Rect, i, tbInbox.FieldByName('Details'+IntToStr(i+1)).AsString,
tbInbox.FieldByName('OpenStatus').AsBoolean ); if Field.FieldName = 'Date' then
begin
Canvas.Font.Color := SetColor(ColorRecord.DateTime);
viWidth := TextRC( Canvas.TextWidth( FormatDateTime( ShortDateFormat,
tbInbox.FieldByName('DateTime').AsFloat )+ ' '+
FormatDateTime( ShortTimeFormat,
tbInbox.FieldByName('DateTime').AsFloat) ),
Rect.Right- Rect.Left, 'C' );
Canvas.Brush.Style := bsClear;
Canvas.TextOut( Rect.Left+2+ viWidth, Rect.Top+2, FormatDateTime( ShortDateFormat,
tbInbox.FieldByName('DateTime').AsFloat )+ ' '+
FormatDateTime( ShortTimeFormat,
tbInbox.FieldByName('DateTime').AsFloat) );
Canvas.Font.Color := OldColor;
end; if Field.FieldName= 'RecipientDetails' then
begin
Canvas.Brush.Style := bsClear;
Canvas.TextOut( Rect.Left+ 2, Rect.Top+ 2, tbInBoxCompanyID.AsString );
i := Canvas.TextHeight('TextOut');
Canvas.TextOut( Rect.Left+ 2, Rect.Top+ 2+ i, tbInBoxCompanyName.AsString); Canvas.Font.Color := SetColor(ColorRecord.StrColor);
Canvas.TextOut( Rect.Left+ 2, Rect.Top+ 2+ i*2, FieldByName('Recipient').AsString );
Canvas.Font.Color := OldColor;
end;
end;
end;