?
Solved

combo box first displayed item

Posted on 2004-04-13
4
Medium Priority
?
197 Views
Last Modified: 2010-05-02
Hi all,
I'd like to know how can I set a particular string as the default item into a combo box (VB 6).

I use a combo box with Style property = 2 (i.e. a dropdown list) to display an ORDERED list of string coming from a db field.
During a search process, the user should choose one of them but he could not choose it at all (because it's not a necessary clause in the criteria), so I manually added to the list the word 'ANY'.
Well, since the combo list is ordered ANY does not appear at the first index and the first cell of the combo is always blank.

So, 2 questions:

I need to have an ordered combo where the first voice is always ANY and ANY must be visible as first element also without any selection on the combo.
Is it possible and how ? (I cannot do this through setting Text property since it's read only)

If I need to know the index number of a given element (string), which function returns it ?



Thanks for any kind of help.
Best,
Irene
0
Comment
Question by:new_irene
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
prgmrdave earned 80 total points
ID: 10814444
I like to use something like "(Any)", in parentheses, because the parentheses sort ahead of any alphabetic characters.

You can cause it to be selected initially using:

cboSearch.ListIndex = 0

There is no function to tell you the index of a given string; you have to search for it:

For I = 0 To cboSearch.ListCount - 1
    If cboSearch.List(I) = sTerm Then
        bFoundIt = True
        Exit For
    End If
Next I

Hope this helps,

David
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 12 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question