how remove paragraph

General TRichView support forum. Please post your questions here
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

how remove paragraph

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you want to implement it as an editing operation (that can be undone by the user)?
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

but i want add or remove event automaticaly
Sorry, I do not understand. Can you explain in another words?
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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").
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, the link to your image does not work.
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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:
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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...
gbg
Posts: 37
Joined: Sun Apr 11, 2010 4:55 pm

Post 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
Post Reply