Results 1 to 8 of 8

Thread: Text property for a Drop Down List

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    Chicago, IL
    Posts
    102

    Angry Text property for a Drop Down List

    I have a form that ties to a database. On the form are three drop down boxes that I want to be drop down lists so that the users have to choose from a restricted selection. However, the box also has to be able to display text when the user is just browsing the records. When I try to insert text from the database into the box I get the good old "Property is read only." Is there a way to either A) Make the drop down list accept an input for the .Text field or B) Make a combobox such that the user has to use one of the existing selections?
    Joe Cody
    Data Integration Engineer
    Novaspect, Inc.
    Elk Grove Village, IL

  2. #2
    Lively Member Harvester's Avatar
    Join Date
    May 2002
    Location
    God's Country
    Posts
    124

    B

    You can remove the ability to type text into the combo box by changing the Style Property to Dropdown List.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    Chicago, IL
    Posts
    102
    I've done that, but then I get "Property is Read-Only" when the database puts a piece of data into the box. Is there a way around this?
    Joe Cody
    Data Integration Engineer
    Novaspect, Inc.
    Elk Grove Village, IL

  4. #4
    Lively Member Harvester's Avatar
    Join Date
    May 2002
    Location
    God's Country
    Posts
    124

    List

    You may have to use the list property to fill the combo box.

    VB Code:
    1. While Not rs.EOF
    2.     ComboBox.List(Index) = rs.Fields(<Your Field>)
    3.     Call rs.MoveNext
    4. Wend

    Thats the basic idea anyway.

    Are you binding this ComboBox to a datasource? If you are then this may not work.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2003
    Location
    Chicago, IL
    Posts
    102
    You're not quite getting what I'm trying to do. I populate the box from code. That's not a problem. But it's bound to a field in the database. When the user is thumbing through records, I get a "Property is Read Only" when it tries to assign the value in the database to the .text field of the drop down list. If I leave the drop down a combo it works fine, but then users can enter whatever they want in the text field and it invalidates my data structure.
    Joe Cody
    Data Integration Engineer
    Novaspect, Inc.
    Elk Grove Village, IL

  6. #6
    Addicted Member
    Join Date
    Aug 2003
    Location
    Singapore
    Posts
    245

    Lightbulb May I Comment?

    May be this helps...
    ComboBox DropDown Style Property
    • 0 - DropDown Combo 'The Text Can Be Edited
    • 1 - Simple Combo 'No Drop Down Just SpinControl
    • 2 - DropDown List 'U Should Select This Then U Have No Problem
    I may have interpret your post wrongly
    Correct me if I made a mistake...
    Hope This Helps.. .....Enjoy Coding.....//


    zak2zak

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You will only get that error if the value does not exist in the drop down list. Are you sure the text is there?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If the text doesn't exist in the combo then add it using
    the .AddItem method.

    Also, you can use the SendMessage API with the
    CB_FINDSTRINGEXACT const. to search the combo and set
    the .ListIndex property to the results. If it is not found then the
    API returns a -1 basically setting the combo text to a Nullstring.
    No errors. If it is found the it sets it to an item in the combo.

    HTH.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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