zoukankan      html  css  js  c++  java
  • DELPHI方面输入EDIT

    procedure TForm1.FormCreate(Sender: TObject);

    var

     i:integer;

    begin

     for i:=0 to ComponentCount-1 do

         if Components[i] is TEdit then

           (Components[i] as TEdit).OnKeyPress:=EditKeyPress;

    end;

    procedure TForm1.EditKeyPress(Sender: TObject; var Key: Char);

    var

     Index:integer;

    begin

     if key=#13 then

     begin

        if ActiveControl.ComponentIndex < ComponentCount-1 then

          Index:=ActiveControl.ComponentIndex+1

        else

          Index:=ComponentCount-1;

        while (not (Components[Index] is TEdit)) and (Index < ComponentCount) do

        begin

          Index:=Index+1;

        end;

        (Components[Index] as TEdit).SetFocus;

        (Components[Index] as TEdit).SelectAll;

     end;

    end;

    这里我们利用了窗体的ActiveControl属性,它代表当前获得焦点的输入文本框;ComponentIndex属性代表了窗体控件放置的次序,也作为本方法中输入框获得焦点的顺序的参考。这个例子所使用方法的难点在于窗体上可以获得焦点的控件也许不止文本框,还有按钮、列表框、复选框等等,如何区分它们需要用到Delphi的运行时信息(RTTI)。另外,该方法有一个局限就是获得焦点的顺序和设计时控件放置的顺序相关。

  • 相关阅读:
    windows下php扩展存在但无法加载的问题
    mysql5.7主从(Master/Slave)同步配置
    windows使用composer.phar
    git untrack file
    git常见问题
    thinkphp框架中Model对象$origin对象的作用
    thinkphp常见问题
    git合并多个commit
    ajax请求post和get的区别以及get post的选择
    .htaccess跳转https
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/1410118.html
Copyright © 2011-2022 走看看