Please help, editing label
Hello,,,
I'm designing a small program, and i have some Labels in it, and i need to edit these labels so when i click on thim a cursor appears and i can move it normally like a textbox and change the label's text and when i click enter the cursor disappears and the label is changed to the new one,,,can some one help me
I hope you could understand my english
thanx
[Edited by Mih_Flyer on 06-01-2000 at 12:26 AM]
Hope it won't be a lousy code
First you need to create a project file with the following control
lblTest (Label)
txtEdit (Text Box)
and the code will look like below:
Code:
Option Explicit
Private Sub lblTest_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'only apply to mouse's left button
If Button = vbLeftButton Then
txtEdit.Top = lblTest.Top
txtEdit.Left = lblTest.Left
txtEdit.Height = lblTest.Height
txtEdit.Width = lblTest.Width
txtEdit.Text = lblTest.Caption
txtEdit.Visible = True
If lblTest.Caption <> "" Then
txtEdit.SelStart = Len(lblTest.Caption)
txtEdit.SetFocus
End If
End If
End Sub
Private Sub txtEdit_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
lblTest.Caption = txtEdit.Text
txtEdit.Visible = False
End If
End Sub
Private Sub txtEdit_LostFocus()
txtEdit.Visible = False
End Sub
Just with TextBox contol will be abit weird
With Textbox alone, the textbox can be highlight by the user at anytime just with the mouse point to the textbox control content. Am I correct? So it may look a bit weird.