Вопрос
Как изменить свойства текста (то есть жирный или курсив, выравнивание в ячейке) в ячейке TStringGrid?
Ответ
procedure TForm1.TotalGridDrawCell(Sender: TObject;
Col, Row: Integer;
Rect: TRect;
State: TGridDrawState);
begin //Determine appearance of individual
cells if gdSelected in State then TotalGrid.Canvas.Brush.Color:= clHighlight
else if gdFixed in State then TotalGrid.Canvas.Brush.Color:= clBtnFace
else TotalGrid.CAnvas.Brush.Color:= clWindow;
if gdFocused in State then begin TotalGrid.Canvas.Font.Color:= clWhite;
TotalGrid.Canvas.DrawFocusRect(Rect);
end
else TotalGrid.Canvas.Font.Color:= clBlack;
//Display left or right justified and/or Bold if (Row = 0)
or (Col = 0) or (TotalGrid.Cells[Col, Row] = '')
then begin TotalGrid.Canvas.Font.Style:= [fsBold];
TotalGrid.Canvas.TextRect(Rect, Rect.Left, Rect.Top, TotalGrid.Cells [Col, Row]);
end else begin TotalGrid.Canvas.Font.Style:= [];
TotalGrid.Canvas.TextRect (Rect, Rect.Right — Canvas.TextWidth(TotalGrid.Cells[Col, Row]), Rect.Top, TotalGrid.Cells [Col, Row]);
end;
end;
Из конференции Expert_FAQ
Copyright 2000-2004 Сообщество Чайников
Контактная информация