A
AndyNakamura
Guest
I have a simple form with just three textboxes and a button.
If you click the button then the content of textbox1 & textbox2 are concatenated together and displayed in textbox3
I want to allow the user to hit enter to do the same thing with the enter key. Is this the correct way?
Option Explicit On
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox3.Text = TextBox1.Text & " " & TextBox2.Text
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _
ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Enter Then
TextBox3.Text = TextBox1.Text & " " & TextBox2.Text
Return True
End If
Return False
End Function
End Class
I notice solutions often have
Return MyBase.ProcessCmdKey(msg, keyData)
But until I know what this does I thought I'd try without it. Anyone can explain I'd be grateful.
Andy
Continue reading...
If you click the button then the content of textbox1 & textbox2 are concatenated together and displayed in textbox3
I want to allow the user to hit enter to do the same thing with the enter key. Is this the correct way?
Option Explicit On
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox3.Text = TextBox1.Text & " " & TextBox2.Text
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _
ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Enter Then
TextBox3.Text = TextBox1.Text & " " & TextBox2.Text
Return True
End If
Return False
End Function
End Class
I notice solutions often have
Return MyBase.ProcessCmdKey(msg, keyData)
But until I know what this does I thought I'd try without it. Anyone can explain I'd be grateful.
Andy
Continue reading...