Beep on Combobox keydown

TexG

Regular
Joined
Apr 2, 2003
Messages
88
Location
San Antonio Texas
Hi all,

I have a combobox on a form the even im working with is the keydown event.

everytime i run the code i ge a window beep when the code finishs in this event.

keycode im looking for is the enter key. got this to work. Just this beep thats driveing me nuts.

Thanks all
 
If you use the KeyPress event, setting e.Handled = True
will suppress the beep. It doesn't seem to be possible with the KeyDown
event though. :-\
 
Didnt work heres my code. can you tell me whats im doing wrong.

Thanks


If Asc(e.KeyChar) = Keys.Return Then

MsgBox("You pressed the Enter button")

e.Handled = True

ElseIf Asc(e.KeyChar) = Keys.Escape Then

MsgBox("You pressed the esc button")

e.Handled = True

Else

MsgBox("What the heck did you press")

e.Handled = True

End If

End Sub
 
What is the code doing? If you're using a MsgBox, then of course
you will get the beep (MsgBoxes cause one). If you're not getting anything
at all... I don't know. So what's the problem?
 
ok here ill try it again but with out the msgbox stuff and still beep

If Asc(e.KeyChar) = Keys.Return Then

ListView1.Items.Clear()

CheckName()

Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & IO.Path.GetDirectoryName(Application.ExecutablePath) & "\DataBase\" & ComboBox1.Text & ".mdb")

MyConnection.Open()

Dim MyCommand As New OleDbCommand("SELECT ID, RefNumber, Description, Cat from " & DataBaseToLookFor & " order by Description", MyConnection)

Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader()

Dim i As Integer

i = 0

While MyReader.Read

ListView1.Items.Add(MyReader("Description"))

ListView1.Items(i).SubItems.Add(MyReader("Cat"))

i += 1

End While

MyConnection.Close()

MyReader.Close()

MyCommand.Dispose()

Resizer()

e.Handled = True

End If

End Sub
 
Well perhaps something else is causing it... this works for me:
Visual Basic:
    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        If Asc(e.KeyChar) = Keys.Enter Then
            e.Handled = True
        End If
    End Sub
 
ok i put the code you sent into a blank form and added a combobox1 to it.
it still beeps.
i then put a breaking point on the
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress

and it beeps as it hits the break.

any other ideals.

thanks
oh i didnt send a msg in the pot for listview resizer of the columns headers. thanks it works great now
 
Unfortunately, I'm using a newer beta version of .NET so you won't
be able to open my projects; that also might be why my code works
for me and not for you. :-\
 
Back
Top