Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

locking text boxes in vb6

Options
  • 24-03-2006 10:43am
    #1
    Closed Accounts Posts: 65 ✭✭


    :D:D can somebody please help me, i want to be able to send text to a text box and then when the data is in the text box i want to lock this data into the text box so that nothing else can be written to the text box

    thanks


Comments

  • Registered Users Posts: 2,082 ✭✭✭Tobias Greeshman


    Send the text to the textbox, then set the textbox's enabled property to false.


  • Registered Users Posts: 431 ✭✭plenderj


    i.e.
      TextBox1.Text = "blah"
      TextBox1.Enabled = False
    

    You may also want to set its BackColor property to vbGrey to ensure the user is aware it's disabled


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    There are three ways of doing what you want to do, and each is suited to particular tasks:

    1) Don't use a textbox...use a Label. Its always read-only

    2) myTextbox.Enabled = false.

    I'd be very careful about setting background colours in the manner plenderi suggested - it generally is based on an assumption that the user is using the same colour-scheme as you...

    3) myTextbox.Locked = true

    This is an all-too-often overlooked feature. The advantage it has over .Enabled = false is that a Locked textbox can still have its text selected and copied.

    Locked textboxes also don't change any foreground/background colours, where Enabled=false should automatically change the font-colour. Depending on what you're doing, either can be a good thing or a bad thing.

    jc

    p.s. in .Net, .Locked changes to .ReadOnly


  • Registered Users Posts: 431 ✭✭plenderj


    Most users should have a default colour scheme enabled though


Advertisement