Can you override the controls KeyPress event in the parent form, and then
just call the KeyPress event for the parent form when your done?
Or else raise a public event in the control and catch it in the parent form
(passing along
(ByVal sender As Object, ByVal e As System.EventArgs)) info and then call
the KeyPress event in the parent?
public class MyControl()
Public Event OnTextBox1KeyPress (ByVal sender as Object, ByVal e As
System.EventArgs)
Private Sub TextBox1_KeyPress (ByVal sender as Object, ByVal e As
System.EventArgs)
'Do something
RaiseEvent OnTextBox1KeyPress (sender,e)
End Sub
End Class
Public Class MyForm
Dim testcontrol as New MyControl
Private Sub testcontrol_KeyPressHandler (ByVal sender as Object, ByVal
e As System.EventArgs) _ Handles testcontrol_OnTextBox1KeyPress
MyForm_KeyPress (sender,e)
End Sub
Private Sub MyForm_KeyPress (ByVal sender as Object, ByVal e As
System.EventArgs) Handles MyForm.KeyPress
'Do Something
End Sub
End Class
I'm sure there is a better way, but this should work fairly easy as well.
Eric Dreksler
"Tom" <to*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a VB.NET user control that I wrote - this control has three or four
other controls on it (textbox, combobox, datetime picker, etc). Now,
whenever the control is on a form and the user enters anything into the
textbox (for instance) I trap the keypress event to handle some stuff
(i.e. if it is an enter key, etc). Now, once I am done with handling the
keypress event for the textbox, I then need to pass that keypress event BACK to the
main form that is hosting the control. I can't just define another
KeyPress event and try a RaiseEvent because the control already has a keypress
event.
I must be brain dead or something today, because normally I should be able
to figure this out but it just isn't coming to me. Once I am done with the
KeyPress event in my control, how can I pass that event (and it's data -
i.e. what key was pressed) back to the host form?
Tom