Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How to Edit Inputs and Set Focus Before Leaving a Windows Forms UserControl

$
0
0

I want to be able to perform a final set of edits before leaving a UserControl and to set the focus on one of the child controls depending on what edit error is detected.   I can invoke the editing method from the UserControl's Validating event handler and cancel the validation when an error is detected, but the MSDN Library documentation for the Control Validating Event says "Do not attempt to set focus from within the Enter, GotFocus, Leave, LostFocus, Validating, or Validated event handlers. Doing so can cause your application or the operating system to stop responding. " (see http://msdn.microsoft.com/en-us/library/system.windows.forms.control.validating.aspx).  So, is there a valid way to do what I want?  I'm programming using Visual C# 2010 Express.   Thanks.

Steve


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>