VB.NET 2010中,如何解决e.Handled属性无效的问题?

2026-05-06 10:021阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计323个文字,预计阅读时间需要2分钟。

VB.NET 2010中,如何解决e.Handled属性无效的问题?

我在VB.NET上做了一个快速的网页浏览器,当我按下Enter键导航到textbox1中的网页时,唯一的问题是每次按下回车键都会发出嘟嘟声。我尝试使用e.Handled=True,但没有发生任何作用。这是“

我在vb.net上做了一个快速的网络浏览器,我有它,所以当你按Enter键导航到textbox1中的网页.唯一的问题就是每次按下回车都会发出哔哔声.我尝试使用e.Handled = True,但它没有做任何事情.这是我的按键代码

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Enter Then e.Handled = True WebBrowser1.Navigate(TextBox1.Text) End If End Sub

我以为e.Handled会让那令人讨厌的嘟嘟声消失,但事实并非如此.

您想要的KeyEventArgs属性不是 Handled而是 SuppressKeyPress.

VB.NET 2010中,如何解决e.Handled属性无效的问题?

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Enter Then e.SuppressKeyPress = True WebBrowser1.Navigate(TextBox1.Text) End If End Sub

从第一个MSDN链接:

Handled is implemented differently by different controls within Windows Forms. For controls like TextBox which subclass native Win32 controls, it is interpreted to mean that the key message should not be passed to the underlying native control. If you set Handled to true on a TextBox, that control will not pass the key press events to the underlying Win32 text box control, but it will still display the characters that the user typed.

If you want to prevent the current control from receiving a key press, use the SuppressKeyPress property.

本文共计323个文字,预计阅读时间需要2分钟。

VB.NET 2010中,如何解决e.Handled属性无效的问题?

我在VB.NET上做了一个快速的网页浏览器,当我按下Enter键导航到textbox1中的网页时,唯一的问题是每次按下回车键都会发出嘟嘟声。我尝试使用e.Handled=True,但没有发生任何作用。这是“

我在vb.net上做了一个快速的网络浏览器,我有它,所以当你按Enter键导航到textbox1中的网页.唯一的问题就是每次按下回车都会发出哔哔声.我尝试使用e.Handled = True,但它没有做任何事情.这是我的按键代码

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Enter Then e.Handled = True WebBrowser1.Navigate(TextBox1.Text) End If End Sub

我以为e.Handled会让那令人讨厌的嘟嘟声消失,但事实并非如此.

您想要的KeyEventArgs属性不是 Handled而是 SuppressKeyPress.

VB.NET 2010中,如何解决e.Handled属性无效的问题?

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Enter Then e.SuppressKeyPress = True WebBrowser1.Navigate(TextBox1.Text) End If End Sub

从第一个MSDN链接:

Handled is implemented differently by different controls within Windows Forms. For controls like TextBox which subclass native Win32 controls, it is interpreted to mean that the key message should not be passed to the underlying native control. If you set Handled to true on a TextBox, that control will not pass the key press events to the underlying Win32 text box control, but it will still display the characters that the user typed.

If you want to prevent the current control from receiving a key press, use the SuppressKeyPress property.