开发者

Key down event of text box in VB.NET

I have to use key down event on text box. Code for the event looks like this:

 Private Sub TextBox1_Keydown(ByVal sender As Object, ByVal e As
 System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyDown   
 If e.KeyCode = keys.Enter Then
    MessageBox.Show("Hello")   
 End If
 End Sub

But it gives the following error:

Handles clause requires a WithEvents variable defined in the containin开发者_如何学运维g type  
or one of its base types. (BC30506) 

what does it mean? what i have to do for this?

Please help me out.

Thanks for your kind help.


Check if the textbox is defined with WithEvents keyword.
Example here.

EDIT: For your case, the definition should look like WithEvents TextBox1 as TextBox


On your {formname}.Designer.vb file check if you have something like this declared on it:

Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜