Search code examples
delphidelphi-xe2mdichild

First control which accepts keyboard input


I have an application which displays different MDI forms. A form contains huge amounts of visual components, and somehow the focus is lost after the form is displayed. I need to find the first control (with the lowest set TabOrder) on the form which accept keyboard input (with a text field e.g. TEdit, TMemo, etc), so I can set the active control to it.

LE: all the controls are created at runtime, and the order of the creation is different based on the business logic.


Solution

  • ...and somehow the focus is lost after the form is displayed.

    My choice would be to answer why that happens and to fix the source of the problem, rather then fixing its implications.

    But to answer the question, you are looking for Form.SelectFirst.