有一个EDIT1,我通过程序让它只能显示不能修改,
但是却怎么也屏蔽不了DELETE键,显示的内容总是会被DELETE键删除。
而且我发现同样的CTRL和ALT键也不行。

解决方案 »

  1.   

    procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if Key = 46 then Key := 0; <---46表示是Delete键
    end;另外你也可以设置ReadOnly属性为True。
    这样就只能读,不能写了。
      

  2.   

    procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if Key = 46 then Key := 0; <---46表示是Delete键
    end;另外你也可以设置ReadOnly属性为True。
    这样就只能读,不能写了。