שתף באמצעות


How to enable keypress event with ComboBox in vb.net

Question

Thursday, June 2, 2011 6:47 PM

Hai

We Could Easily Called A Functions By Pressing Enter In keypress Event. On textbox in vb.net. Eg.:-

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then

Call Fsn()

End If

But. I can not called the functions on ComboBox. IN similar fashion. please help me to called a Funtion when we press ENTER IN ComboBox.

Thanking You In Advance.

All replies (6)

Thursday, June 2, 2011 7:10 PM ✅Answered | 2 votes

Hai

We Could Easily Called A Functions By Pressing Enter In keypress Event. On textbox in vb.net. Eg.:-

If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then

Call Fsn()

End If

But. I can not called the functions on ComboBox. IN similar fashion. please help me to called a Funtion when we press ENTER IN ComboBox.

Thanking You In Advance.

Hello inaocha,

 

I hope you understand what you need, you have to handle KeyDown event of the combobox in this way.

 

 Private Sub ComboBox1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
  If e.KeyCode = Keys.Enter Then
   'your code here
  End If
 End Sub

 

 

Hello

Carmelo La Monica  http://community.visual-basic.it/carmelolamonica/


Friday, June 3, 2011 8:39 AM

Thank you monica

 

Inaocha


Friday, June 3, 2011 8:40 AM

Thank you monica

 

Inaocha

Hello Inaocha,

 

you're Welcome:)

 

Hello

Carmelo La Monica  http://community.visual-basic.it/carmelolamonica/


Saturday, May 11, 2013 8:43 AM

I am working in VS 2010 C#.

I want to retreive whether Enter key is pressed on a combo box(txtAddress) in toolstrip.

I started the function as: private void txtAddress_KeyDown(object sender, EventArgs e)

The e.KeyCode, e.KeyValue etc are not showing up.

Only four options show up when I press "." after the parameter e.They are Equals, GetHashCode, GetType, ToString.

What might be the problem??


Saturday, May 11, 2013 11:51 AM | 1 vote

I am working in VS 2010 C#.

I want to retreive whether Enter key is pressed on a combo box(txtAddress) in toolstrip.

I started the function as: private void txtAddress_KeyDown(object sender, EventArgs e)

The e.KeyCode, e.KeyValue etc are not showing up.

Only four options show up when I press "." after the parameter e.They are Equals, GetHashCode, GetType, ToString.

What might be the problem??

Hi,

 This is the Visual Basic forum. You will have better luck getting an answer on the C# forum. Here is the link to the C# forum.  :)

http://social.msdn.microsoft.com/Forums/en-us/csharpgeneral/threads


Friday, March 25, 2016 3:40 PM

Private Sub cbArticulos_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cbArticulos.KeyPress
        Select Case Asc(e.KeyChar)
            Case 13
                cbArticulos.SelectedValue = cbArticulos.Text
        End Select
End Sub