Right after call AddNLTag() how can I get the correct ItemInfo? rve.GetCurrentItem?
Thanks
How to get newly inserted item??
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: How to get newly inserted item??
Add*** methods append data to the end of the document.
If this method adds a single item (like rv.AddNLTag), you can access it using the index rv.ItemCount - 1.
For example:
If you call Add*** method that can add multiple items (such as AddTextNL), you can compare the value of ItemCount before and after to calculate how many items are added to the end.
You cannot use GetCurrent*** methods to get information about items added by Add*** methods.
GetCurrent*** methods return information about the item at the caret position.
After calling Add*** methods the document is unformatted until you call Format, and the caret position is undefined.
GetCurrent*** methods can be used after editing methods for insertion (Insert***) - but only if this insertion was successful. Insertion may fail because of text protection, or if multiple table cells were selected.
Most insertion methods return True on success:
If this method adds a single item (like rv.AddNLTag), you can access it using the index rv.ItemCount - 1.
For example:
Code: Select all
rv.AddNLTag('Hello', 0, 0, 'greetings');
Caption := rv.GetItemText(rv.ItemCount - 1) + rv.GetItemTag(rv.ItemCount - 1);
You cannot use GetCurrent*** methods to get information about items added by Add*** methods.
GetCurrent*** methods return information about the item at the caret position.
After calling Add*** methods the document is unformatted until you call Format, and the caret position is undefined.
GetCurrent*** methods can be used after editing methods for insertion (Insert***) - but only if this insertion was successful. Insertion may fail because of text protection, or if multiple table cells were selected.
Most insertion methods return True on success:
Code: Select all
if rve.InsertPicture(…) then
rve.GetCurrentPictureInfo(…)