• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

selecting an item in a list or combobox

I typically maintain list and combo boxes with the record id in the 0th column.

I know in a list for instance, it's easy to select the value you want if you know it's index; but what if you only know the value of of the record id (ie, employeeID)

What's the best way to select it in the list (and make sure it scrolles into view?

How about for a combo box.

Any tips and advice much appreciated!
0
efinger
Asked:
efinger
  • 5
1 Solution
 
Shiju SasidharanCommented:

List1.Selected(index)=True
0
 
Shiju SasidharanCommented:
where index is the index of the item u want to make as selected
eg:

index =3
List1.Selected(index)=True
0
 
Shiju SasidharanCommented:
oops combo ?
ok
try to set the combo text


   Combo1.Text = your_Employee_Id

if its  style is - 2 then it may generate error if the id u try to set is not in the combo
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Shiju SasidharanCommented:
otherwise go through each entry and check ur matching string is reached ...

http://forums.aspfree.com/archive/t-34576/Automatically-selecting-text-in-a-ComboBox-Dropdown-List
0
 
Shiju SasidharanCommented:
for better solution
use winSendMessageS function specified in the above link
0
 
iHadiCommented:
Hi

Add a listBox to a vb project (List1) and try this code

' Add 100 item to test on
For i = 1 To 100
    List1.AddItem "Item " & CStr(i)
    ' we use item data that holds custom numeric data (ID in our case)
    ' because listindex could be different than the ID especially if
    ' the IDs have a number missing in the middle
    List1.ItemData(List1.NewIndex) = i
Next

For i = 1 To List1.ListCount
    If List1.ItemData(i) = 50 Then
        ' if we find the item we select it and exit the loop
        List1.ListIndex = i
        Exit For
    End If
Next
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now