• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Setfocus back to previously disabled Edit

On my form I have one TEdit which always has the focus with the flashing cursor inside it which clearly shows the user where the focus is.  At some point this edit is disabled for a few seconds than re-enabled. After re-enabling, the cursor no longer flashes inside the edit, even if I do a edit1.setfocus.  If there was text selected prior to the disabling, the text no longer shows as selected (although it is still in fact selected) when re-enabling.  Any suggestions on how to fix that.  I know tabbing to another field than back soves it but that I would prefer not to do that.
0
moonrise
Asked:
moonrise
  • 3
1 Solution
 
viktornetCommented:
Hello moonrise... Here is the answer to your question...

with DisabledEdit do begin
  SetFocus;
  SelStart := 1;
  SelLength := Length(Text);
end;

That's all I guess...

Regards,
Viktor Ivanov

0
 
viktornetCommented:
Here is a simpler way...

DisabledEdit.SetFocus;
DisabledEdit.SelectAll;

Regards,
Viktor Ivanov
0
 
moonriseAuthor Commented:
Have you tried it ? It does not seem to work for me.

Thank you.
0
 
viktornetCommented:
No I haven't ... I'll take a look at it in a second....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now