|
-
May 31st, 2000, 10:52 AM
#1
Thread Starter
Addicted Member
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]
-
May 31st, 2000, 01:55 PM
#2
Addicted Member
You can't actually edit the Label control that I am aware of, you kind of want a hybrid Label/TextBox... im not sure how much this will help you, but you could try this...
Code:
Private Sub Label1_DblClick()
Label1.Caption = InputBox("Enter the new value for Label1...", "English is Cool", Label1.Caption)
End Sub
-
May 31st, 2000, 03:06 PM
#3
PowerPoster
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
-
May 31st, 2000, 04:14 PM
#4
Hyperactive Member
Just use a textbox
Set the following properties:
Appearance 0 - Flat
Border Style 0 - None
Change the background colour to the form colour and
voila....you have a text box that looks like a lable and can be edited.

Dan
[Edited by Judd on 06-01-2000 at 05:19 AM]
-
May 31st, 2000, 04:32 PM
#5
PowerPoster
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.
-
Jun 1st, 2000, 04:06 AM
#6
Not if you set the Enabled property to False. If it is set to false, then you will not be able to highlight it, in which case, it will act as a label.
-
Jun 1st, 2000, 07:01 AM
#7
PowerPoster
yup
yup, Megatro you're rite. But with the Enabled properties set to False, then all the text within the TextBox control will be in gray color rite?
-
Jun 1st, 2000, 07:04 AM
#8
Yes, it will be in gray, but i'm sure you can change that with API.
-
Jun 1st, 2000, 07:09 AM
#9
PowerPoster
yup, I think SendMessage API can do this.
-
Jun 1st, 2000, 10:48 AM
#10
Junior Member
Easy Solution
Don't Make a Label. Make textbox and set the following properties:
Appeareance = Flat
BorderStyle = None
BackColor = The backcolor of form
These properties would make your textbox look like label and users would be able to edit it also.
Kazim Zaidi (the cracker)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|