How to get newly inserted item

General TRichView support forum. Please post your questions here
Post Reply
cychia_n2n
Posts: 16
Joined: Mon May 09, 2016 9:16 am

How to get newly inserted item

Post by cychia_n2n » Mon Feb 27, 2017 12:02 pm

Right after call AddNLTag() how can I get the correct ItemInfo? rve.GetCurrentItem?

Thanks

Sergey Tkachenko
Site Admin
Posts: 14398
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to get newly inserted item

Post by Sergey Tkachenko » Mon Feb 27, 2017 12:48 pm

Add*** methods add items to the end of the document. So the index of the new item is rve.ItemCount - 1, and you can use rve.GetItem(rve.ItemCount - 1).

You cannot use GetCurrent*** methods. They work with the item at the position of the caret. This position is undefined until you format the document.

Note: AddText*** methods may add multiple items, if string contains line breaks, tabs, or page break characters. To calculate how many items are added, you can compare values of rve.ItemCount before and after the call.

Post Reply