• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • 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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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