C# KeyPress Event

0 views
Skip to first unread message

Tal

unread,
Jul 25, 2005, 5:08:11 PM7/25/05
to DotNetDe...@googlegroups.com
I'm trying to make a chat dialog and I want that when the user will
click on the "Enter" button it will do an action.. is the event
KeyPress is the right one and how do i know if the enter button was
really pressed ?

Message has been deleted

Jonathan Dickinson

unread,
Jul 28, 2005, 1:21:59 AM7/28/05
to DotNetDe...@googlegroups.com
Ah! U forgot something! The keypreview property on the form must be set to True.

 
On 26/07/05, Ekremweb <Ekrem...@gmail.com> wrote:

First of all I don't understand which button? Is it the <Enter> Button
on the keyboard or is it a button on the form?
if it's on the keybrd;

this can help you :

Private Sub detectenter(ByVal e As
System.Windows.Forms.KeyPressEventArgs)
       Dim a As Char = e.KeyChar
       Dim s As Object = a.GetHashCode
       If s = 851981 Then 'if the pressed key is enter
        messagebox.show("Enter pressed")
       End If
   End Sub

  Private Sub TxtChatMain_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
       detectenter(e)
   End Sub




--
Thanks

Jonathan Dickinson
----------------------------
Phone: +27 15 276 5007
Cell: +27 73 559 4721
Email: jonathanc...@gmail.com
Reply all
Reply to author
Forward
0 new messages