在表单显示之前,如何强调组件的重点 [英] How to force a focus on a component before the Form is shown

查看:144
本文介绍了在表单显示之前,如何强调组件的重点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须显示(with showModal)一个具有许多TEdit的表单,但是我想强调TEdit的重点,但不一定总是相同的,具体取决于上下文。

I have to show (with showModal) a Form with many TEdit but I want to force the focus on a TEdit, but not always the same, depending on the context.

我不能在ShowModal之前使用SetFocus(因为窗体不激活),并且在我的应用程序中使用组件名称或标签不方便。
你有一个想法吗?

I can't use SetFocus before the ShowModal (because the Form is not activate) and use the Component Name or Tag is not convenient in my application. Do you have an idea ?

推荐答案

在我看来,实现你的目标的最简单的方法是分配到 ActiveControl 表单的属性。您可以在显示表单之前进行此操作。当您的表单稍后显示时,VCL框架将确保 ActiveControl 被输入焦点。

The simplest way to achieve your goal, in my view, is to assign to the ActiveControl property for the form. You can do this before showing the form. When you form is later shown, the VCL framework will ensure that the ActiveControl is given input focus.

文档


如果表单没有焦点, ActiveControl 是表单接收焦点时将接收焦点的控件。 / p>

If the form does not have focus, ActiveControl is the control on the form that will receive focus when the form receives focus.

这篇关于在表单显示之前,如何强调组件的重点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆