Results 1 to 12 of 12

Thread: [RESOLVED] how to keep components readonly?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2008
    Posts
    47

    Resolved [RESOLVED] how to keep components readonly?

    how can i make my...

    • text box
    • list box
    • date picker
    • combo box


    read-only? i know the .enabled = false; property but it turns the forecolor to gray which i dont want.

    i want the color to stay as black (normal) but the user should not be able to ammend it until he clicks the edit button.

    PS: I am willing to do this for the navigation of records (move first, move next, move previous, move last).

    hope i made my self clear.

    thanks.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to keep components readonly?

    Textbox - set the locked property to true
    Listbox - don't really need to do anything as nothing can be added to it without code
    Date Picker - same thing
    Combo box - set the locked property to true

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2008
    Posts
    47

    Re: how to keep components readonly?

    Private Sub txt_name_GotFocus()
    cmd_close.SetFocus
    End Sub


    this works actually what i want to do; but this is lame if i do this for all fields and components.

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2008
    Posts
    47

    Re: how to keep components readonly?

    Quote Originally Posted by Hack
    Textbox - set the locked property to true
    Listbox - don't really need to do anything as nothing can be added to it without code
    Date Picker - same thing
    Combo box - set the locked property to true
    i dont even want the text to be highlighted :S i tried using locked property before but it still highlights the text.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to keep components readonly?

    Then you will need to write code for each and every text box etc on your form.

    Do you want to go that route?

  6. #6
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: how to keep components readonly?

    if you want to stop the contents of highlighting, set the enabled property to False. I think that since DISABLED state is let's say Windows default you may have to let it go. I had a similar problem, and unless you have all the time in the word to code each field separately and to debug it afterwards: get on with the forecolor :P

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to keep components readonly?

    Quote Originally Posted by tatkosmurff
    if you want to stop the contents of highlighting, set the enabled property to False.
    He doesn't want to do that.

    Typically, I when I need something like this, I will put the code in each individual textbox. It is more effort on my part, but the users (and they are the ones that count) like it.

  8. #8
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: how to keep components readonly?

    It doesn't worth the effort if you ask me. It is good to follow the user's wishes, but this may lead you to a terrible chaos.
    Right now I am stuck alone in an enormous ERP-like project because I tried to ensure that all user wishes will be completed. DO NOT MAKE MY MISTAKE.
    User must be tolerated to optimize the application GUI, maybe the application performance, but it must be clear for "IT" that is you who takes the decisions.

  9. #9
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Indiana
    Posts
    295

    Re: how to keep components readonly?

    Why have a textbox that's Read Only? If you want something that's read-only, then use a label instead of a textbox.

    You can make the label look just like a textbox with borders, colors, and so on.

    The only difference in your code then is: Label1.Caption = "something" instead of Textbox1.Text = "something".

    If you want the user to be able to change it after clicking the edit button, then you could to something like this:

    Make a regular textbox. Then create a label directly on top of the textbox, exactly the same size and look. Have your program write to both the label and the textbox. Have the textbox visible property set to false, and the label visible property set to true.

    When the user clicks the edit button, have the label visible property go to false, and the textbox property go to true.

    This will do what you want.

    Edited: Add attachment: Form
    Attached Files Attached Files
    Last edited by Caskbill; Jan 30th, 2008 at 11:05 AM.

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2008
    Posts
    47

    Re: how to keep components readonly?

    ummmm so many ways to go still moral of the solution code code & code

    thanks everyone.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to keep components readonly?

    Quote Originally Posted by tatkosmurff
    It doesn't worth the effort if you ask me.
    It is worth the effort if that is what is on the spec sheet that finds its way into your In-box.

  12. #12
    Lively Member
    Join Date
    Jul 2007
    Posts
    98

    Re: [RESOLVED] how to keep components readonly?

    yes you are right about that

    EOF

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