我也是查以前的贴知道的
procedure TZFMF.GridZHJDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
vText:PChar;
begin
with TStringGrid(Sender) do
begin
if ARow=0 then Canvas.font.color:=clMaroon
else Canvas.font.color:=clWindow;//clBlack;
vText := PChar(Cells[ACol, ARow]);
Canvas.FillRect(Rect);
DrawText(Canvas.Handle, vText, StrLen(vText), Rect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE); //<<--
{ TODO : 修改对齐方式 }
if gdFocused in State then begin
Rect.Left := Rect.Left + 1;
Rect.Top := Rect.Top + 1;
Rect.Right := Rect.Right - 1;
Rect.Bottom := Rect.Bottom - 1;
Canvas.DrawFocusRect(Rect);
end;
end;
prcedure TForm1.IsEdit;
begin
with stringgrid1 do
begin
if col=4 then
options:=[goFixedVertLine,goFixedHorzLine,goColMoving,goEditing]
else
options:=[goFixedVertLine,goFixedHorzLine,goColMoving]
end;
end;