Solved

combo box first displayed item

Posted on 2004-04-13
4
191 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
4 Comments
 
LVL 1

Accepted Solution

by:
prgmrdave earned 20 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now