在Delphi中DBGrid默认是不显示Memo字段值的,我找到一个例子可以用DBMemo来显示。虽然可以实现,问题是不能在DBGrid中Memo所在的位置下显示。
我所做的系统中DBGrid是放在Form下的panel控件上的,代码如下:
procedure TMainForm.DBGrid9DrawDataCell(Sender: TObject; const Rect: TRect;
  Field: TField; State: TGridDrawState);
begin
   if(gdfocused in state) then
   begin
      if(Field.fieldname=dbmemo1.datafield) then
      begin
         //用dbmemo1显示'所需设备'字段的内容
         dbmemo1.left:=rect.left+dbgrid9.left+panel3.Left;
         dbmemo1.top:=rect.top+dbgrid9.top+panel3.Top;
         dbmemo1.width:=rect.right-rect.left;
         dbmemo1.visible:=true;
      end;
      if(field.fieldname=dbmemo2.datafield) then
      begin
         //用dbmemo2显示'备注'字段的内容
         dbmemo2.left:=rect.left+dbgrid9.left;
         dbmemo2.top:=rect.top+dbgrid9.top;
         dbmemo2.width:=rect.right-rect.left;
         dbmemo2.visible:=true;
      end;
   end;
end;请各位帮忙看一下,为什么显示的位置是运行前dbmemo所在的地方,而不是当前memo字段所在的位置。就好像上面的代码没有执行一样!