procedure TForm1.ADODataSet1MaterielNameGetText(Sender: TField;
var Text: string; DisplayText: Boolean);
var
lSingleWidth: integer;
lDBGridWidth: integer;
begin
lSingleWidth := DBGrid1.Canvas.TextWidth('壹');
lDBGridWidth := DBGrid1.Columns[1].Width;
if DBGrid1.Canvas.TextWidth(Sender.AsString) <= lDBGridWidth then
Text := Sender.AsString
else if DBGrid1.Canvas.TextWidth(Sender.AsString) > lDBGridWidth then
begin
lSingleWidth := lDBGridWidth div lSingleWidth - 1;
if lSingleWidth mod 2 = 1 then
lSingleWidth := lSingleWidth + 1;
Text := Copy(Sender.AsString, 1, lSingleWidth) + '...';
end
end;