|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Insert key press in text boxI am making a program whereby when the insert key is pressed in a text box it opens up another form with the search parameters they entered in the text box and automatically searches for the data. I have the code below however it does not work when i press the insert key. I have tried it with the enter key Ascii code 13 and all works fine! Is it something to do with Insert being a system/bios key? My code is below; Private Sub TelephoneTxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TelephoneTxt.KeyPress 'handle telphone number search Dim key As Char = Microsoft.VisualBasic.ChrW(45) If e.KeyChar = key And TelephoneTxt.Text = "" And SurnameTxt.Text = "" Then MsgBox("Please enter at least one of the two search parameters") ElseIf e.KeyChar = key Then CustomerSearch.ShowDialog() CustomerSearch.CustomerReservationSearch(SurnameTxt.Text, TelephoneTxt.Text) End If End Sub Any help is much appreciated Thanks James
Show quote
Hide quote
"jimmy" <james.herring***@tiscali.co.uk> wrote in message The KeyPress event doesn't fire for the insert key, as it doesn't produce a news:1165349547.362492.80840@16g2000cwy.googlegroups.com... > Hi all > > I am making a program whereby when the insert key is pressed in a text > box it opens up another form with the search parameters they entered in > the text box and automatically searches for the data. I have the code > below however it does not work when i press the insert key. I have > tried it with the enter key Ascii code 13 and all works fine! Is it > something to do with Insert being a system/bios key? My code is below; > > Private Sub TelephoneTxt_KeyPress(ByVal sender As Object, ByVal e > As System.Windows.Forms.KeyPressEventArgs) Handles > TelephoneTxt.KeyPress > 'handle telphone number search > Dim key As Char = Microsoft.VisualBasic.ChrW(45) > If e.KeyChar = key And TelephoneTxt.Text = "" And > SurnameTxt.Text = "" Then > MsgBox("Please enter at least one of the two search > parameters") > ElseIf e.KeyChar = key Then > CustomerSearch.ShowDialog() > CustomerSearch.CustomerReservationSearch(SurnameTxt.Text, > TelephoneTxt.Text) > End If > End Sub > > > Any help is much appreciated > > Thanks > > James > James, character (e.KeyChar). You can use the KeyDown or KeyUp event to trap the Insert key; Private Sub TelephoneTxt_KeyDown(ByVal sender As Object, ByVal e As System. _ Windows.Forms.KeyEventArgs) Handles TelephoneTxt.KeyDown ' Handle telphone number search If e.KeyCode = Keys.Insert And TelephoneTxt.Text = "" And SurnameTxt.Text = "" Then MsgBox("Please enter at least one of the two search parameters") ElseIf e.KeyCode = Keys.Insert Then CustomerSearch.ShowDialog() CustomerSearch.CustomerReservationSearch(SurnameTxt.Text, TelephoneTxt.Text) End If End Sub Hope that helps. _____________________________ The Grim Reaper On 5 Dec 2006 12:12:27 -0800, jimmy wrote:
Show quoteHide quote > Private Sub TelephoneTxt_KeyPress(ByVal sender As Object, ByVal e Hey james,> As System.Windows.Forms.KeyPressEventArgs) Handles > TelephoneTxt.KeyPress > 'handle telphone number search > Dim key As Char = Microsoft.VisualBasic.ChrW(45) > If e.KeyChar = key And TelephoneTxt.Text = "" And > SurnameTxt.Text = "" Then > MsgBox("Please enter at least one of the two search > parameters") > ElseIf e.KeyChar = key Then > CustomerSearch.ShowDialog() > CustomerSearch.CustomerReservationSearch(SurnameTxt.Text, > TelephoneTxt.Text) > End If > End Sub > > Any help is much appreciated > > Thanks > > James Try the KeyDown event instead
Close a form after x amount of time
Confusing Arraylist BinarySearch problem Re: Is VB.NET Popular??? Is there some way to tell the debugger not to stop at WndProc? set focus Mask and dates Complete Newbie Need some info about the Load event of Forms and Usercontrols How to Step back to caller in break mode Max Pool Size question |
|||||||||||||||||||||||