Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Avoiding the "ding" sound when pressing Enter on a editable combobox

10 views
Skip to first unread message

Carlos J. Quintero

unread,
Mar 25, 2002, 6:25:24 AM3/25/02
to
When you put a TextBox and an ediatble ComboBox (DropDownStyle=DropDown) on
a form with no AcceptButton, pressing the Enter key when the focus is on any
of those controls causes an annoying "ding" sound.

Using this trick I can avoid the "ding" sound on the TextBox:

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If
End Sub

But this does not work for the ComboBox:

Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
End If
End Sub

It seems that the combobox has a textbox inside and when the KeyPress event
of the combo is fired, the internal TextBox has emitted the "ding" sound.

In VB6, this did not happen with comboboxes, only with textboxes. <g>

Is there an easy workaround for this, before resorting to subclassing and
the such?

Best regards,

Carlos


Mike

unread,
Mar 25, 2002, 10:00:03 AM3/25/02
to
Perhaps use KeyDown event instead? Seemed to be the only one that didn't
ding for me.

private void mTaskDsp_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
// If the enter key is pressed, consider the task name entry
done
if( e.KeyCode == Keys.Enter )
{
CompleteAddTaskName();
}
}

Mike


"Carlos J. Quintero" <carlos_j_quinter...@hotmail.com> wrote
in message news:Oz30R$#0BHA.2620@tkmsftngp07...

Carlos J. Quintero

unread,
Mar 25, 2002, 10:12:43 AM3/25/02
to
No, that was the first event that I tried, but that event does not work even
for TextBoxes.

Carlos

"Mike" <mtsch...@earthlink.net> wrote in message
news:#V4Mv2A1BHA.2308@tkmsftngp04...

0 new messages