Results 1 to 7 of 7

Thread: [RESOLVED] Don't let the user type in a ComboBox

  1. #1

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Resolved [RESOLVED] Don't let the user type in a ComboBox

    They should only be able to click the combo to get the options, not type their own entry in.
    I've tried .locked and that stops the user from selecting anything, while .enabled obviously just greys it out completely.
    I thought of using the combo's change event to check if the user changed it to something that doesn't match any of the proper options, but that's probably a pretty dirty way of doing it.

    cheers,
    metal

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Don't let the user type in a ComboBox

    Do you want to disbale all the key pressing? If so, use the keypress event.

    EG:
    Code:
    Private Sub Combo1_KeyPress(KeyAscii As Integer)
        KeyAscii = 0
    End Sub
    IIF(Post.Rate > 0 , , )

  3. #3

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: Don't let the user type in a ComboBox

    Awesome, thanks.

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: [RESOLVED] Don't let the user type in a ComboBox

    in addition to ZeeZee's suggession,
    i thing if you put the combobox
    Code:
    Me.Combo1.Style = 2
    would also work.

  5. #5

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: [RESOLVED] Don't let the user type in a ComboBox

    Even better! Ta guys

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

    Re: [RESOLVED] Don't let the user type in a ComboBox

    I prefer zeezee's method. When you change the style it removes the text property. However, disabling keypress has the same effect, but leaves the text property of the combo for use in code.

  7. #7

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: [RESOLVED] Don't let the user type in a ComboBox

    Yeah, I see what you mean, but for this particular instance Fazi's is better. I'll definitely remember zeezee's for the future though. That would come in handy for validation in textboxes. ie if keyascii = somebadcharacter then keyascii = 0

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