procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (Key in ['0'..'9']) then Key := Chr(0); end;
----------------------------------------------
非得 偶来写吗 真让 偶不省心: procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin edit1.ReadOnly :=false; if (key<48) or (key>57) then begin edit1.ReadOnly :=true; if (key=8) or (key=46) then edit1.ReadOnly :=false; end; end;
----------------------------------------------
if (Key in ['A'..'Z', 'a'..'z']) then Key := Chr(0); 如果按下的键是'A'-'Z','a'-'z'那么取消按键 嘿嘿 这个代码只屏蔽a-z,A-Z 看清楚哦~
----------------------------------------------
if not (key in [#48..#57,#8]) then key:=#0 {如果不是0到9和退格键无效}
----------------------------------------------
秋风清 秋月明,几上闲琴黯生尘。 夜来忽忆少年事,陌上柳绿草青青。 相逢一笑言未语,携手相看自倾心。 二十二载云烟里,云含风韵烟含情。 风尘渺落风霜浸,但闻长空雁长鸣。 姿容如花颜如玉,只在平生梦里寻。 秋风清 秋月明,秋灯秋雨愁煞人。 天涯路远人何在,午夜梦回空扰惊。
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (ssctrl in shift) and ((key=118) OR (key=86)) then edit1.PasteFromClipboard; end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin If (pos(Key,'0123456789') = 0) and (Key <> #8) Then Key := #0; end;
----------------------------------------------
-