//按下ENTER键代替TAB键if key=#13 then
begin
key:=#10;
selectnext(activecontrol,true,true);
end
begin
key:=#10;
selectnext(activecontrol,true,true);
end
解决方案 »
- delphi 自定义的类 类的实例的create语句应该放在哪里?
- 用idhttp,post数据,cookie的问题
- 《DELPHI开发技术大全》哪里有下的
- delphi中不通过idhttp控件来实现http代理连接的代码?
- 如何从服务器上下载文件到本地?
- 如何能解决这样的问题?希望有源码!
- 如何调用外部程序?
- 为什么用QuickReport的QRShape画的线条打印出来的效果不是很直,是抖动的线条呢?
- 如何让DBGRID的TEXTBOX改成COMBOBOX或其他控件
- SQLDMO没人用过啊?怎样用TBackup对象,我把它装到DELPHI里运行出错?
- 请问如何使用AppendRecord方法插入在表中含有自动增长(AutoInCrement)类型的一条记录。
- 申请csdn数据库管理版的版主
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
//按下ENTER键代替TAB键
if key=#13 then
begin
key:=#10;
selectnext(activecontrol,true,true);
end
end;然后在别的edit的属性里面就能找到这个,procedure了,这样就可以引用了
uses CommDeclare, Classes, TypInfo;//過濾在編輯框的輸入字符
procedure FilterInput(EditList: array of TComponent;
fiType: TFIType);//檢測某個控件是否存在某個屬性
function HasProperty(aComponent: TComponent;const PropName: string): Boolean;implementation//過濾在編輯框的輸入字符
procedure FilterInput(EditList: array of TComponent;
fiType: TFIType);
procedure NoSpaceKeyPress(self: TObject;Sender: TObject; var Key: Char);
begin
if Key=#32 then
Key := #0;
end;
procedure IntegerKeyPress(self: TObject;Sender: TObject; var Key: Char);
begin
if not (Sender is TComponent) then
Exit;
if not (Key in ['0'..'9','-',#8,#46,#13]) then
Key := #0;
if Key='-' then
if HasProperty(TComponent(Sender),'Text') then
if Length(GetStrProp(Sender,'Text'))>0 then
Key := #0;
end;
procedure NoSignIntKeyPress(self: TObject;Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,#46,#13]) then
Key := #0;
end;
procedure FloatKeyPress(self: TObject;Sender: TObject; var Key: Char);
var
TextValue: string;
begin
if not (Sender is TComponent) then
Exit;
if not (Key in ['0'..'9','.','-',#8,#46,#13]) then
Key := #0; if Key='-' then
if HasProperty(TComponent(Sender),'Text') then
if Length(GetStrProp(Sender,'Text'))>0 then
Key := #0;
if Key='.' then
if HasProperty(TComponent(Sender),'Text') then
begin
TextValue := GetStrProp(Sender,'Text');
if Pos('.',TextValue)<>0 then
Key := #0;
if Pos('.',TextValue)=1 then
SetStrProp(Sender,'Text','0.');
end;
end;
procedure NoSignFloatKeyPress(self: TObject;Sender: TObject; var Key: Char);
var
TextValue: string;
begin
if not (Sender is TComponent) then
Exit;
if not (Key in ['0'..'9','.',#8,#46,#13]) then
Key := #0; if Key='.' then
if HasProperty(TComponent(Sender),'Text') then
begin
TextValue := GetStrProp(Sender,'Text');
if Pos('.',TextValue)<>0 then
Key := #0;
if Pos('.',TextValue)=1 then
SetStrProp(Sender,'Text','0.');
end;
end;
procedure DateKeyPress(self: TObject;Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9','-',#8,#46,#13]) then
Key := #0;
end;
var
aMethod: TMethod;
iLoop: integer;
begin
case fiType of
fiNoSpace: aMethod.Code := @NoSpaceKeyPress;
fiInteger: aMethod.Code := @IntegerKeyPress;
fiNoSignInt: aMethod.Code := @NoSignIntKeyPress;
fiFloat: aMethod.Code := @FloatKeyPress;
fiNoSignFloat: aMethod.Code := @NoSignFloatKeyPress;
fiDate: aMethod.Code := @DateKeyPress;
else ;
end;
aMethod.Data := nil;
for iLoop := Low(EditList) to High(EditList) do
SetMethodProp(EditList[iLoop],'OnKeyPress',aMethod);
end;//檢測某個控件是否存在某個屬性
function HasProperty(aComponent: TComponent;const PropName: string): Boolean;
var
PropInfo: PPropInfo;
begin
PropInfo := GetPropInfo(aComponent.ClassInfo,PropName);
Result := PropInfo<>nil;
end;end.公共單元,加上
if key=#13 then
begin
key:=#10;
selectnext(activecontrol,true,true);
end
比如keypress,注意参数要一致