|
-
Aug 14th, 2003, 11:46 AM
#1
Thread Starter
Lively Member
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
-
Aug 14th, 2003, 12:03 PM
#2
Lively Member
B
You can remove the ability to type text into the combo box by changing the Style Property to Dropdown List.
-
Aug 14th, 2003, 12:05 PM
#3
Thread Starter
Lively Member
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
-
Aug 14th, 2003, 12:16 PM
#4
Lively Member
List
You may have to use the list property to fill the combo box.
VB Code:
While Not rs.EOF
ComboBox.List(Index) = rs.Fields(<Your Field>)
Call rs.MoveNext
Wend
Thats the basic idea anyway.
Are you binding this ComboBox to a datasource? If you are then this may not work.
-
Aug 14th, 2003, 12:23 PM
#5
Thread Starter
Lively Member
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
-
Aug 18th, 2003, 06:40 AM
#6
Addicted Member
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
-
Aug 18th, 2003, 07:16 AM
#7
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
-
Aug 18th, 2003, 09:59 AM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|