mpappert Posted February 10, 2003 Posted February 10, 2003 I've heard that you can somehow make a form return true or false, probably by overriding the windows form class somehow ... Here is my problem: I have a form that I am trapping KeyPress events (turning KeyPreview On) and checking the key's for validity (this is for reading a magnetic stripe) ... it has specific characters that mark the beginning and end of the "data string" ... so I watch for these using the KeyPress event ... if I am able to get all the data successfully then I want the form to return True and go through validation, if it didn't read the swipe properly then it returns False, so a warning can be displayed to the user and they can swipe the card again ... Any ideas? Thanks (again)! M. Quote
*Gurus* divil Posted February 10, 2003 *Gurus* Posted February 10, 2003 The form has a built-in method for doing this. When you call ShowDialog() on a form, it returns one of many dialog result constants, the most common of which are Ok and Cancel. In your form, as soon as you set the dialogresult, the form will hide and code will return to the calling procedure. DialogResult = DialogResult.Cancel 'or DialogResult = DialogResult.Ok Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.