dcsimg
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
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    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.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  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
  •  



Featured


Click Here to Expand Forum to Full Width