Page 1 of 1

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

Posted: Thu Nov 25, 2010 3:20 pm
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?

Posted: Thu Nov 25, 2010 3:53 pm
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;

Posted: Thu Nov 25, 2010 4:24 pm
by chuqingsheng
thank-you very much for your quick reply . I will try