Solved

prevent lose focus

Posted on 2016-09-15
6
57 Views
Last Modified: 2016-09-20
Is there a way to prevent/cancel a lost focus event in a .NET desktop app?
0
Comment
Question by:HLRosenberger
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41800475
the whole app or a specific control?
0
 
LVL 26

Assisted Solution

by:Shaun Kline
Shaun Kline earned 125 total points
ID: 41800524
If you need to cancel the lost focus due to validation, you can use the validating event which has that capability.
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 250 total points
ID: 41800635
Just to add to Shaun Kline

See Control.Validating Event


If the Cancel property of the CancelEventArgs is set to true in the Validating event delegate, all events that would usually occur after the Validating event are suppressed.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 125 total points
ID: 41801062
Be very careful - it could end up the only way to use the PC is to pull the power cable out and power it up again.
1
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 250 total points
ID: 41804258
Just in case. I have found the following article that might be interesting:
http://geekswithblogs.net/dapostolov/archive/2009/06/14/the-validating-event-can-prevent-a-form-closing-properly.aspx
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41806750
thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question