Can delete the chat message,and delete from db?

General TRichView support forum. Please post your questions here
Post Reply
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Can delete the chat message,and delete from db?

Post by greatsea »

The chat message is saved into db.OK.
Load from db and display them on the richview(or readonly richviewEdit).OK.

For example:
Me: 2011-11-26 22:00
Hello

Tom: 2011-11-26 22:01
Hi

................

Now,how can delete some message?as so:delete the message:
Tom: 2011-11-26 22:01
Hi

and delete it from db at same time.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I need more information.
How this message is stored, how it is loaded.
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Post by greatsea »

Thank you,Sergey.
The message is stored into db as below:
PKID sayname saytime saycontent etc.

Load is as below:
AddTextNL(); //display sayname,saytime
InsertRVFFromStream(); //display message content

I don't know how to insert the PKID into richview and not know how to select the section and get the PKID.
Maybe use the table cell?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What is PKID?
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Post by greatsea »

The PKID is the primary key of table.
By the PKID, delete the record from table will can be done:
Delete from T_MSGCHAT where PKID = xx

The records of T_MSGCHAT looks like:

PKID sayname saytime saycontent etc.
1 me 2011-11-26 11:20 Hello ....
2 Tom 2011-11-26 11:21 Hi ....
3 .......................................
4 .......................................
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I think PKID can be stored in the tag of the first string. Use AddNLTag instead of AddTextNL (I assume that the first string do not contain line breaks).
Deleting:

Code: Select all

for i := 0 to rv.ItemCount-1 do
  if StrToIntDef(RVData.GetItemTag(i), -1)=PKID then begin
    rv.DeleteParas(i, i);
    break;
  end;
This code assumes that saytext+saytime+message occupies one paragraph. Otherwise, you need to adjust the parameters of DeleteParas.
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Post by greatsea »

Thank you very much,Sergey.
The Tag is a good idea,and I test that all is ok.
The RichView have a lots of great thinks,thank you again.
Post Reply