Delete items cascade
Posted: Tue Sep 21, 2010 11:54 am
Is need to delete several items (defined by tags) when user deletes some item with specified tag.
Seems like I can't use OnItemAction event:
And execution is fails on srveContent.RichViewEdit.Format;
Any suggestions?
Seems like I can't use OnItemAction event:
Code: Select all
procedure TForm1.OnItemAction(Sender: TCustomRichView;
ItemAction: TRVItemAction; Item: TCustomRVItemInfo;
var Text: TRVRawByteString; RVData: TCustomRVData);
begin
if (ItemAction = rviaMovingToUndoList) and (Item.Tag > 0) then
begin
DeleteItems(-Item.Tag);
srveContent.RichViewEdit.ClearUndo;
srveContent.RichViewEdit.Format;
end;
end;
procedure TForm1.DeleteItems(const ATag: Integer);
var
Finder: TItemFinder; {Performs searching sequence of items with specified tag and return RVData in which sequence is founded, start item no and items count.}
begin
Finder := TItemFinder.Create(ATag, srveContent.RichViewEdit.RVData);
try
if Finder.Search then
begin
Finder.RVData.SetSelectionBounds(Finder.Start, 0, Finder.Start, 0);
Finder.RVData.DeleteItems(Finder.Start, Finder.Count);
end;
finally
Finder.Free;
end;
end;
Any suggestions?