3

我编写了一个 TDBGrid 后代组件,它显示当前所选行的不同 blob 字段的内容,每个字段都在 TJvDBrichEdit 中。用于显示 blob 字段内容的DrawColumnCell代码:

procedure TMyDBGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var iPos,iNr,iTop:Integer;
begin
 // RBA 01/04/2013 12:10
if not (csDesigning in ComponentState) then
 if FDisplayBlobAsRTF then //property to show the blob fields or not
  begin
  if (gdSelected in State) then
    begin
     if Column.Field.isblob then
      begin
        ipos := 0;
        iNr := 0;
        while (iPos <= Column.Field.DataSet.FieldCount-1)and(Column.Field.DataSet.Fields[ipos].FieldName <> Column.Field.FieldName ) do
         begin
          if Column.Field.DataSet.Fields[ipos].IsBlob then
           inc(iNr);
          inc(iPos);
         end;
        with TJvDBRichEdit(FRichEditList[inr]) do//FRichEditList - TObjectList which contains all the TJvDBRichEdit components, and release them on destroy
         begin
          Left := Rect.Left + Self.Left + 1;
          iTop :=  Rect.Top + Self.Top + 1;
          if iTop + Height > Self.Height then
           iTop := iTop - Height;
          Top := iTop;
          Width := Rect.BottomRight.X - Rect.left;

          Visible := true;
         end;
      end;
    end
  end;
  inherited;
end;

覆盖的LayoutChanged例程

procedure TMyDBGrid.LayoutChanged;
var iPos : Integer;
    dtDataset : TDataSet;
    jvDbRichEdit : TJvDBRichEdit;
begin
 if not (csDesigning in ComponentState) then
 if FDisplayBlobAsRTF then
  begin
    dtDataset := GetDataset;//get the dataset assigned to the grid
    if dtDataset <> nil then
    if dtDataset.State <> dsInactive then
     begin
      FRichEditList.Clear;
      for iPos := 0 to dtDataset.FieldCount-1 do
       if dtDataset.Fields[iPos].IsBlob then
        begin
         jvDbRichEdit := TJvDBRichEdit.Create(nil);
         jvDbRichEdit.Parent := Self;
         jvDbRichEdit.DataSource := Self.DataSource;
         jvDbRichEdit.DataField := dtDataset.Fields[iPos].FieldName;
         jvDbRichEdit.Visible := false;
         FRichEditList.Add(jvDbRichEdit);
        end;
     end;
  end;
end;

当我在最后显示的网格行上滚动时出现问题:

在此处输入图像描述

如何重绘后面的网格?我试过重新粉刷孔网格,但它在闪烁。

LE:这不是为了修改richedtis中的内容,只是为了显示它们。

4

0 回答 0