Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Search in ListBox

Posted on 1999-07-03
2
Medium Priority
?
186 Views
Last Modified: 2010-08-05
How can I search for text in a ListBox?
0
Comment
Question by:jackjoker
[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
2 Comments
 
LVL 2

Expert Comment

by:333
ID: 1386016
you can walk through all items in your ListBox and compare them with your search string:

var
  i: integer;

for i:=0 to ListBox1.Items.Count-1 do
  if ListBox1.Items[i]=SearchString then
    {found a string}

I posted this as comment, maybe somebody knows a better way to do this

A.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 0 total points
ID: 1386017
hi jackjoker,

so can it be done

var I : Integer;
begin
  I := ListBox1.Items.IndexOf(Edit1.Text);  //Examine
  If I > -1 then                                          //Check, and do what you want
    ListBox1.ItemIndex := I  //Select
  else
    ListBox1.Items.Add(Edit1.Text);  //Add to list
end;

meikl
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

715 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