Results 1 to 10 of 10

Thread: Please Help

  1. #1

    Thread Starter
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241

    Thumbs down 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]

  2. #2
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155

    Talking

    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

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Talking 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

  4. #4
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Talking 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]

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Smile 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.


  6. #6
    Guest
    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.

  7. #7
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Smile 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?






  8. #8
    Guest
    Yes, it will be in gray, but i'm sure you can change that with API.

  9. #9
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    yup, I think SendMessage API can do this.

  10. #10
    Junior Member
    Join Date
    May 2000
    Location
    New Delhi, India
    Posts
    18

    Lightbulb 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
  •  



Click Here to Expand Forum to Full Width