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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

locking text boxes in vb6

  • 24-03-2006 9: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, Registered Users 2 Posts: 2,082 ✭✭✭Tobias Greeshman


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


  • Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 431 ✭✭plenderj


    Most users should have a default colour scheme enabled though


Advertisement