Page 1 of 2

how remove paragraph

Posted: Wed Jun 16, 2010 2:37 pm
by gbg
how i can remove lines or paragraph and shift up other line or paragraph

example :

Line1
Line2
Line3
Line4

after Delete Line2 show me:

Line1
Line3
Line4

Posted: Wed Jun 16, 2010 6:48 pm
by Sergey Tkachenko
Do you want to implement it as an editing operation (that can be undone by the user)?

Posted: Thu Jun 17, 2010 11:42 am
by gbg
Sergey Tkachenko wrote:Do you want to implement it as an editing operation (that can be undone by the user)?
yes, user can not add text
i want show event in richveiw and remove it afte my process done

Posted: Sun Jun 20, 2010 6:14 pm
by Sergey Tkachenko
If the user cannot edit this document, I understand you need a non-editing procedure.
Also, I assume that you need to delete a paragraph.

The most simple way is using DeleteParas method.
This method assumes that the document is formatted. It also leaves the document formatted (so it is unique among non-editing method).
In the parameters of this method, you need to specify the index of any item belonging to the paragraph to delete.

For example, to delete the paragraph N (counted from 1):

Code: Select all

procedure DeleteParagraph(rv: TCustomRichView; N: Integer);
var i: Integer;
begin
  for i := 0 to rv.ItemCount-1 do
    if rv.IsFromNewLine(i) then begin
      dec(N);
      if N=0 then begin
        rv.DeleteParas(i, i);
        exit;
      end;
    end;
end;

Posted: Wed Jun 23, 2010 7:16 pm
by gbg
If the user cannot edit this document, I understand you need a non-editing procedure.
Also, I assume that you need to delete a paragraph.
user cannot edit
but i want add or remove event automaticaly

Posted: Thu Jun 24, 2010 12:40 pm
by Sergey Tkachenko
but i want add or remove event automaticaly
Sorry, I do not understand. Can you explain in another words?

Posted: Mon Jun 28, 2010 8:03 pm
by gbg
user can not edit or add text manually , richveiw is read only
but my program can add message or event or question and answer ( such as "Are you sur? Yes i want , No thanks") to richveiw :roll:
and i want when user clicked on answer , program delete question and answer or replace with new Text (example : "You chose NO").

Posted: Wed Jun 30, 2010 3:19 pm
by Sergey Tkachenko
So, as I see, you have 3 text items in the paragraph:
1) question
2) answer 1
3) answer 2
You can use DeleteItems to delete answers, then SetItemText to change text in question to the chosen answer. Then call Format.

Posted: Sun Jul 25, 2010 4:36 pm
by gbg
thanks
but how add lines and how remove
i can not find sample
in richview i can add many question and answer and user maybe answer 1 or 2 question,how i understand user answer which question?

Posted: Mon Jul 26, 2010 6:23 pm
by Sergey Tkachenko
Deleting lines - rv.DeleteItems.
Inserting lines in middle - no documented methods for this. I can give you a code for this, but probably it is possible to avoid inserting lines, and modify text of existing lines instead.

Please send me two "screenshots" - what you want to see before and after.
I'll give you a code how to implement it.

Posted: Tue Jul 27, 2010 7:16 pm
by gbg
Image
this is chat box
Item 1 add by server and item 2 and 3 is two Choice for user
if user click on item 2 I want remove Item 1
if user click on item 3 i want replace item 1 by other text

Posted: Wed Jul 28, 2010 9:37 am
by Sergey Tkachenko
Sorry, the link to your image does not work.

Posted: Wed Jul 28, 2010 3:37 pm
by gbg
Sergey Tkachenko wrote:Sorry, the link to your image does not work.
i upload here http://rapidshare.com/files/409611616/chat.png
and i see image on previous post :roll:

Posted: Thu Jul 29, 2010 6:37 am
by Sergey Tkachenko
I understand the following:

You have 2 hyperlinks in the same paragraph.
If the user clicks on the first hyperlink, you need to remove the first item in this paragraph. The rest of the paragraph remains unchanged.
If the user clicks on the second link, you want to change text in the first item of this paragraph. The rest of the paragraph remains unchanged.

But what if the user clicks on the first item in this paragraph again? The first item is already removed...

Posted: Thu Jul 29, 2010 10:34 am
by gbg
hi
item 1 is 2 line (or 3 line)
and i add line 1 to item 1 :
ReciveText.AddNLWTag(uname+'......',0,0,0); <----- text in line 1
and i add line 2 to item 1 :
ReciveText.AddNLWTag('.....',0,0,0); <---- text before item 2
ReciveText.AddNLWTag('......',3,-1,100); <---- this is item 2
ReciveText.AddNLWTag('.......',0,-1,0); <---- text after item 2 and before item 3
ReciveText.AddNLWTag('......',3,-1,101); <---- item 3
ReciveText.AddNLWTag('......',0,-1,0); <---- text after item 3
ReciveText.Format;

now i want when user click on item 2 ,application clear 2 lines in item 1 and item 2 and item 3
when click on item 3 ,application replase 2 lines in item 1 and item 2 and item 3 by other text and lines