How to delete blank lines?
The following code works:
rvP1.DeleteSelection;
if rvP1.GetCurrentItemText = '' then
rvP1.DeleteParas(rvP1.CurItemNo, rvP1.CurItemNo);
BUT not when selection is in a table cell (previously the code has done a rvP1.SearchText( 'some text', [rvseoDown] ).
How to write something which will work inside and outside a table ??
Thanks
Deleting Blank Lines
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Should it be an editing operation (that can be undone/redone by user)?
If not, the code is below:
Call:
If not, the code is below:
Code: Select all
procedure 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;
Code: Select all
DeleteBlankLines(RichView1.RVData);
RichView1.Format;
Last edited by Sergey Tkachenko on Tue Sep 06, 2005 8:53 pm, edited 3 times in total.
fix to code above
Thanks Sergei - works great -- but note
the line rv.DeleteItems(i,1) needs to be
rvData.DeleteItems(i,1)
the line rv.DeleteItems(i,1) needs to be
rvData.DeleteItems(i,1)
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17522
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: