Click here to Skip to main content
12,501,082 members (41,385 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Hi friends
i write a code like

Private Sub flash_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyCode = Keys.Escape Then
        Me.Close()
    End If
End Sub
In vb.net the code is work.But when i drag and drop the shack wave flash object control on form designing after i run the form the above code does not work.How can i rectify this problem???
Advance thanks to all.....
Posted 5-Nov-12 7:47am
Updated 5-Nov-12 7:56am
ridoy58.6K
v3
Comments
   
"Does not work" is not informative enough. What exactly the problem is? And what is "Me" here? A form? Why closing it in this strange way? If this is a modal window, it's closed by itself; you need to have CancelButton.
--SA
SPprasath 5-Nov-12 14:01pm
   
Thank u....
   
You are welcome.
If you agree that my answer makes sense, please accept it formally (green button) -- thanks.
--SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This is not a good way to close a window. If you show a window as modal (via ShowDialog), you need to use CancelButton; and the form will close itself on escape:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.cancelbutton.aspx[^].

And if the form is not modal, you should never close it with Escape, as it will violated expected UI style and can cause loss of user's work, by apparent reasons.

—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100