trichview.com Forum Index trichview.com
TRichView support forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Example] How to move caret to the paragraph

 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6576

PostPosted: Sun Aug 28, 2005 10:25 am    Post subject: [Example] How to move caret to the paragraph Reply with quote

A very simple example: how to move caret to the beginning of the n-th paragraph

Code:
procedure GoToParagraph(rve: TCustomRichViewEdit; ParagraphIndex: Integer);
var i: Integer;
begin
  for i := 0 to rve.ItemCount-1 do begin
    if rve.IsParaStart(i) then
      dec(ParagraphIndex);
    if ParagraphIndex<0 then begin
      rve.SetSelectionBounds(i, rve.GetOffsBeforeItem(i), i, rve.GetOffsBeforeItem(i));
      rve.Invalidate;
      exit;
    end;
  end;
end;

Call:
Code:
GoToParagraph(RichViewEdit1, 7);

ParagraphIndex is zero-based.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group