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.
Can delete the chat message,and delete from db?
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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?
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?
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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 .......................................
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 .......................................
-
- Site Admin
- Posts: 17572
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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:
This code assumes that saytext+saytime+message occupies one paragraph. Otherwise, you need to adjust the parameters of DeleteParas.
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;