Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
Edited 5-Nov-12 7:56am
ridoy51.8K
v3
Comments
Sergey Alexandrovich Kryukov at 5-Nov-12 13:50pm
   
"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 at 5-Nov-12 14:01pm
   
Thank u....
Sergey Alexandrovich Kryukov at 5-Nov-12 14:37pm
   
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
0 Sergey Alexandrovich Kryukov 458
1 OriginalGriff 344
2 George Jonsson 233
3 Animesh Datta 130
4 Shemeemsha RA 128
0 OriginalGriff 6,179
1 Sergey Alexandrovich Kryukov 5,616
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 5 Nov 2012
Copyright © CodeProject, 1999-2014
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