Page 1 of 1
How to get the ItemNumber of an existing String?
Posted: Thu Jul 27, 2006 3:48 pm
by RichEnjoyer
Hello,
how can i get the number of an existig Item?
I have...
RichView1.AddNL('MyFirstLine',0,0);
RichView1.Add('example',1);
RichView1.Format;
now i search the ItemNumber of "MyFirstLine" ?
Is it possible to get the ItemNumber?
best regrads, Frank
Posted: Sat Jul 29, 2006 12:38 pm
by Sergey Tkachenko
The simplest way is to store item index at the moment of document generation:
Code: Select all
MyFirstLineItemNo := RichView1.ItemCount;
RichView1.AddNL('MyFirstLine',0,0);
RichView1.Add('example',1);
RichView1.Format;
or you can search for it:
Code: Select all
MyFirstLineItemNo := -1;
for i := 0 to RichView1.ItemCount-1 do
if RichView1.GetItemTextA(i)='MyFirstLine' then begin
MyFirstLineItemNo := i;
break;
end;
Of course, this code returns the proper value only if there is no another text item with 'MyFirstLine' text.
Posted: Sun Jul 30, 2006 12:00 am
by RichEnjoyer
Ok thanks,
it works fine!
i make the edit with...
rvAdd.SetItemText(intP+POS_MSGCNT,IntToStr(intMsgCnt));
is work good.
How change the ParaStyle?
I want switsh to ParaStyle No 2 when the intMsgCnt>5.
It is posibble?
best regrads, Frank
Posted: Sun Jul 30, 2006 7:57 am
by Sergey Tkachenko
rvAdd.GetItem(i).ParaNo := new_value.
But very important: all items in the same paragraph must have the same value of ParaNo, otherwise the document will be invalid.
(the i-th item starts a new paragraph, if rvAdd.IsParaStart(i)=True)