Reputation: 57343
I've got a simple little WPF app with a TextBox and a WebBrowser control. As I type into the TextBox the WebBrowser updates with its content.
But on each keystroke, when the WebBrowser updates, it makes a click sound. How can I disable the WebBrowser control's refresh click sound?
WPF TextBox and WebBrowser controls http://img411.imageshack.us/img411/2296/appbz9.jpg
My XAML...
<TextBox Name="MyTextBox"
...
TextChanged="MyTextBox_TextChanged"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalScrollBarVisibility="Visible" />
<WebBrowser Name="MyWebBrowser" ... />
My Visual Basic code...
Private Sub MyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) If Not MyTextBox.Text = String.Empty Then MyWebBrowser.NavigateToString(MyTextBox.Text) Else MyWebBrowser.Source = Nothing End If End Sub
Upvotes: 2
Views: 2708
Reputation: 572
That click is becouse of the navigation, doing that without it should not appear.
I would introduce a div tag of mine in an empty HTML loaded in the webbrowser and in the moment of updating I would introduce the text of the textbox in the innerHTML property of the div. Without navigation.
Visual Basic code...
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
MyWebBrowser.NavigateToString("<html><body><div id=""MyDiv""></div></body><html>")
End Sub
Private Sub MyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs)
MyWebBrowser.Document.GetElementById("MyDiv").InnerHtml = MyTextBox.Text
End Sub
Upvotes: 2
Reputation: 12854
Well it's using IE7/8 container if I'm not mistaken so it may need to be done through Windows Sounds.
Upvotes: 2