Page 1 of 1
Can delete the chat message,and delete from db?
Posted: Sat Nov 26, 2011 2:24 pm
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.
Posted: Sat Nov 26, 2011 4:36 pm
by Sergey Tkachenko
Sorry, I need more information.
How this message is stored, how it is loaded.
Posted: Sat Nov 26, 2011 5:28 pm
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?
Posted: Sat Nov 26, 2011 6:15 pm
by Sergey Tkachenko
What is PKID?
Posted: Sun Nov 27, 2011 5:47 am
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 .......................................
Posted: Sun Nov 27, 2011 9:46 am
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.
Posted: Sun Nov 27, 2011 3:44 pm
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.