sgt_pinky
Regular
Hi,
What is the correct way to do this. I have a windows forms app, and I want several of the forms to close when I press escape.
So I have the general sub-routine in say 6 different forms, all with the same code:
In order to make my app more manageable, I could put the one subroutine in a general class, and just use AddHandler in the Form_Load() sub of each form.
I was wondering if there was some better way that I could do it, using Inherits or something like that.
This is a simple example, the actual code that I want to do this with is a class that is used to drag a skinned form, based on some specific controls.
Cheers,
Pinky
What is the correct way to do this. I have a windows forms app, and I want several of the forms to close when I press escape.
So I have the general sub-routine in say 6 different forms, all with the same code:
Visual Basic:
Private Sub CloseFormOnEscape(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cmbSkin.KeyPress
If Asc(e.KeyChar) = Keys.Escape Then Me.Close()
End Sub
In order to make my app more manageable, I could put the one subroutine in a general class, and just use AddHandler in the Form_Load() sub of each form.
I was wondering if there was some better way that I could do it, using Inherits or something like that.
This is a simple example, the actual code that I want to do this with is a class that is used to drag a skinned form, based on some specific controls.
Cheers,
Pinky