I have been perplexed by trying to use a ComboBox in a DropDown style for a Web browser app. There is this very annoying DING! sound (Windows system error sound) when pressing enter.
I have tried a few suggestions to no avail. I am using VS 2008.
This does not affect it when changing the style but I need the DropDown in order to make and save a "history" of sites visited.
I'd like to find a solution, if anyone has any ideas? Thanks! Here is something I have been trying...
Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown Dim objcboBox As New ClasscboBox objcboBox.KeyDown(objcboBox, New KeyEventArgs(Keys.Enter)) If e.KeyCode = Keys.Enter Then ComboBox1.Items.Add(ComboBox1.Text) WebBrowser1.Navigate(ComboBox1.Text) Me.Text = (ComboBox1.Text) 'SaveHistory() e.Handled = True ' <- This keypress has been handled, no more processing for that End If End Sub
ublic Class ClasscboBox Inherits ComboBox Protected Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs) If e.KeyChar = ControlChars.Cr Then e.Handled = True Else MyBase.OnKeyPress(e) End If End Sub 'OnKeyPress Public Shadows Sub KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) If e.KeyCode = Keys.Enter Then ' Enter could be trapped in KeyDown event e.Handled = True Else MyBase.OnKeyDown(e) End If End Sub 'KeyDown End Class
-Tom


Sign In
Create Account

Back to top









