renaming active control from handler

M

Marc

Hi all,

The code below works fine....however i am trying to find a way of
renaming the active button control with the text entered in the
'newtxtbox' ,instead of opening a message box! -see MsgBox("test
message") when enter is clicked).

any ideas?

-----------------------------------------------------------------------------------

Private Sub RenameToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RenameToolStripMenuItem.Click
Dim NewTxtBox As New TextBox
NewTxtBox.Location = ContextMenuStrip1.SourceControl.Location
Me.Controls.Add(NewTxtBox)
NewTxtBox.BringToFront()
NewTxtBox.Text = "Type and Hit Enter"
AddHandler NewTxtBox.KeyPress, AddressOf TextBox1_KeyPress
End Sub

---------------------------------------------------------------------------------------------------------------------------------

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Chr(Keys.Enter) Then
MsgBox("test message")
End If
End Sub
 
R

Ryan S. Thiele

Read from your other post.

--
--
Thiele Enterprises - The Power Is In Your Hands Now!
--
Hi all,

The code below works fine....however i am trying to find a way of
renaming the active button control with the text entered in the
'newtxtbox' ,instead of opening a message box! -see MsgBox("test
message") when enter is clicked).

any ideas?

-----------------------------------------------------------------------------------

Private Sub RenameToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RenameToolStripMenuItem.Click
Dim NewTxtBox As New TextBox
NewTxtBox.Location = ContextMenuStrip1.SourceControl.Location
Me.Controls.Add(NewTxtBox)
NewTxtBox.BringToFront()
NewTxtBox.Text = "Type and Hit Enter"
AddHandler NewTxtBox.KeyPress, AddressOf TextBox1_KeyPress
End Sub

---------------------------------------------------------------------------------------------------------------------------------

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Chr(Keys.Enter) Then
MsgBox("test message")
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top