我把代码贴上让大家帮忙看一下。
procedure TSummaryRptForm.SummaryRptGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
Var iRect : TRect;
Xi,Yi : Integer;
iStr : String;
begin
//***** Draw Left Column *******
iStr := 'E1';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 4) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 3).Left;
iRect.Top := CellRect(ACol,ARow - 3).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
iStr := 'E2';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 11) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 6).Left;
iRect.Top := CellRect(ACol,ARow - 6).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
iStr := 'E3';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 14) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 2).Left;
iRect.Top := CellRect(ACol,ARow - 2).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
iStr := 'MFG';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 25) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 10).Left;
iRect.Top := CellRect(ACol,ARow - 10).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
iStr := 'OPC';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 26) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 0).Left;
iRect.Top := CellRect(ACol,ARow - 0).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
iStr := 'TD';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 32) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 5).Left;
iRect.Top := CellRect(ACol,ARow - 5).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
iStr := 'QE';
With TStringGrid(Sender) Do
begin
IF (ACol = 0) and (ARow = 33) Then
begin
Canvas.Brush.Color := clBackground;
Canvas.Font.Color := clWhite;
iRect.Left := CellRect(ACol,ARow - 0).Left;
iRect.Top := CellRect(ACol,ARow - 0).Top;
iRect.Right := CellRect(ACol,ARow).Right;
iRect.Bottom := CellRect(ACol,ARow).Bottom;
Xi := (iRect.Right - iRect.Left - Canvas.TextWidth(iStr)) Div 2;
Yi := (iRect.Bottom + iRect.Top - Canvas.TextHeight(iStr)) Div 2;
Canvas.FillRect(iRect);
Canvas.TextOut(Xi,Yi,iStr);
end;
End;
end;