question about delete blank lines in TDBRichviewEdit

General TRichView support forum. Please post your questions here
Post Reply
dutboy
Posts: 5
Joined: Mon Nov 14, 2005 12:19 pm

question about delete blank lines in TDBRichviewEdit

Post by dutboy »

Dear sir:
I use on TDBRichViewEdit assocated with database. And I use the code of "delete blank lines " found in this forum which are behind:

Code: Select all

procedure TfrmMain.DeleteBlankLines(RVData: TCustomRVData);
var
  i,r,c: Integer;
  table: TRVTableItemInfo; 
begin
  for i := RVData.ItemCount-1 downto 0 do 
    if RVData.IsParaStart(i) and (RVData.GetItemStyle(i)>=0) and 
      (RVData.GetItemText(i)='') and (RVData.ItemCount>1) then 
      RVData.DeleteItems(i,1)  
    else if RVData.GetItemStyle(i)=rvsTable then begin 
      table := TRVTableItemInfo(RVData.GetItem(i)); 
      for r := 0 to table.Rows.Count-1 do 
        for c := 0 to table.Rows[r].Count-1 do 
          if table.Cells[r,c]<>nil then 
            DeleteBlankLines(table.Cells[r,c].GetRVData); 
    end;
end;
The code works correctly. But it doesn't write back to the database!
What's the matter ?
How can I write to the database after I delete blank lines ?

Thank you.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

I think you may be missing the following:
Before modifying things call:
if (!RichViewEdit->CanChange()) return;
And after the modifications, you should call:
RichViewEdit->Change();

The above would go "around" the call to DeleteBlankLines() (or any viewer-style method(s)).
Sergey has explained this in more detail somewhere (do a search if you like).

Hope this helps,

Michel
dutboy
Posts: 5
Joined: Mon Nov 14, 2005 12:19 pm

That's good!

Post by dutboy »

Thanks a lot!

Bingo!

Thank you.
Post Reply