curItemNo doesn't seem to change

General TRichView support forum. Please post your questions here
Post Reply
baileyrc
Posts: 11
Joined: Fri Apr 27, 2007 11:44 pm

curItemNo doesn't seem to change

Post by baileyrc »

Should the curItemNo property be incremented every time an object is inserted?

e.g. if a loop had the contents

Code: Select all

   RichViewEdit1->CurItemNo;
   RichViewEdit1->InsertBullet(0,imageList);
Shouldn't CurItemNo grow?

My problem is that CurItemNo remains fixed at 0 no matter how many times the loop is executed. ItemCount remains fixed at 1 in a similar manner.

I need to accurately store CurItemNo before each InsertBullet so that I can call SetBulletInfoEd with the proper ItemNo.

I'm obviously missing something here.[/code]
baileyrc
Posts: 11
Joined: Fri Apr 27, 2007 11:44 pm

Post by baileyrc »

Okay -- I exaggerated a bit... The first time through the loop curitem and itemcount don't change (they stay at 0 and 1 respectively). After the second time through the loop they increment properly. Why wouldn't these change after the first pass???
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It's better to use this code:

Code: Select all

if (RichViewEdit1->InsertBullet(0, ImageList))
{
  RichViewEdit1->SetCurrentBulletInfo(...)
}
If you want to use SetBulletInfoEd,

Code: Select all

if (RichViewEdit1->InsertBullet(0, ImageList))
{
  RichViewEdit1->TopLevelEditor->SetBulletInfoEd(RichViewEdit1->TopLevelEditor->CurItemNo, ...)
}
Two things are important:
1) InsertBullet may fail, for example if multiple table cells are selected. So check the returned value.
2) When accessing current item by its index, use TopLevelEditor property.

As for non-incrementing CurItemNo.
When you insert bullet in empty line, the bullet replaces text item, so CurItemNo is not changed (one item is removed, one item is added).
Post Reply