how to forbid all itemtype insert into the cell except text?

General TRichView support forum. Please post your questions here
Post Reply
chuqingsheng
Posts: 38
Joined: Sat Nov 06, 2010 5:12 am

how to forbid all itemtype insert into the cell except text?

Post by chuqingsheng »

I have some cells in table. user can insert, modify the cell text, but don't allow insert other item type into it.
how to do?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Non-text items can be either pasted from Clipboard or inserted by a drag&drop.
To prevent inserting non-text items by drag&drop, you can assign rve.AcceptDragDropFormat := [rvddText, rvddUnicodeText]. Or you can forbid accepting drag&drop by assigning rve.AcceptDragDropFormat := [].

As for pasting, you can use OnPaste event. This code allows pasting only a plain text:

Code: Select all

procedure TForm1.rvePaste(Sender: TCustomRichViewEdit;
  var DoDefault: Boolean);
var s: String;
begin
  if Clipboard.HasFormat(CF_TEXT) then begin
    s := Clipboard.AsText;
    rve.InsertText(s, False);
  end;
  DoDefault := False;
end;
chuqingsheng
Posts: 38
Joined: Sat Nov 06, 2010 5:12 am

Post by chuqingsheng »

thank-you very much for your quick reply . I will try
Post Reply