Windows Develop Bookmark and Share   
 index > Windows Forms General > calling KeyChar attribute on programatically added textbox with keypress event
 

calling KeyChar attribute on programatically added textbox with keypress event

Hi,

i have added a textbox programatically and added a handler to the keypress event.

when the keypress fires, i am looking for e.KeyChar but it doesn't exists.

can someone please assist?

my code:

private sub test ()

dim mySearchBox as textbox

me.Controls.Add(mySearchBox)

AddHandler mySearchBox.KeyPress, AddressOf mySearchBox_KeyPress

end sub

Protected Sub mySearchBox_KeyPress(ByVal sender As Object, ByVal e As EventArgs)

msgbox asc(e.KeyChar)

end sub


erez
bkerez  Friday, January 23, 2009 10:38 PM
Your event signature is wrong. It should be Byval e As KeyPressEventArgs.



Hans Passant.
nobugz  Saturday, January 24, 2009 2:12 AM
Your event signature is wrong. It should be Byval e As KeyPressEventArgs.



Hans Passant.
nobugz  Saturday, January 24, 2009 2:12 AM
Hi, By defult complier will generate syntax error for you before running the application. This is becuasesignature error you have
Pr.wa'el
Pr.Wael  Wednesday, January 28, 2009 1:32 PM

You can use google to search for other answers

Custom Search

More Threads

• treeview treenode backcolor reverts to dark blue after mouseup
• Listbox ??
• How to enable/disable the close button('X') in window form ?
• Able to detect SerialDataReceiveEvent in a function?
• Formatting a string for an IP Address.
• Moving Control at runtime not working properly
• Switch between different windows forms
• using existing event args
• How to remove the "X" button on my Windows dialog boxes
• How to disable perticular cell in DataGridViewControl ?