菜鸟求助:在EDIT中编辑时如何在按下"-"(#$2D)时把其直接转换成"~"(#$A1AB)? 在EDIT中编辑时如何在按下"-"(#$2D)时把其直接转换成"~"(#$A1AB)?例如:输入 '0-1',在Edit中显示为'0~1' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);begin if Key = '-' then Key := '~';end; procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);begin if Key = '-' then Key := '~';end; Sorry, 看错了符号用如下代码试试procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);var S: string; iPos: Integer;begin if Key = '-' then begin Key := #0; S := Edit2.Text; iPos := Edit2.SelStart; Insert('~', S, iPos + 1); Edit2.Text := S; Edit2.SelStart := iPos + 2; end;end; 请问怎样访问父窗体的变量? QQ登陆不了,很郁闷!什么原因啊?请大家赐教! 请高手解答!FastReport 怎样直接修改和打印.frp格式的文件 请问一些软件所用的数据库究竟是什么 比较简单的问题,我的方法比较麻烦,大家有没什么比较简单的方法! 谁有DBTreeView控件?收到马上送50分! 小妹要哭 !!!!··字体问题··解决者高分赠送!!!!!!! 救命呀,DELPHI窗体显示WORD文档(文档中有多个网格),在线等待,高分送上! 如何实现ctrl+c和ctrl+v? 一个调用的小问题,请各位大虾指教 关于DBgrid的数据插入
begin
if Key = '-' then
Key := '~';
end;
begin
if Key = '-' then
Key := '~';
end;
用如下代码试试procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
var
S: string;
iPos: Integer;
begin
if Key = '-' then
begin
Key := #0;
S := Edit2.Text;
iPos := Edit2.SelStart;
Insert('~', S, iPos + 1);
Edit2.Text := S;
Edit2.SelStart := iPos + 2;
end;
end;