?
Solved

Hiding Items in Listbox

Posted on 2003-03-22
4
Medium Priority
?
1,709 Views
Last Modified: 2008-03-10
I'm trying to make a gui-search similar to winamp's jump feature. This requires me to hide items in the listbox. I looked, but I don't thing that a normal listbox has this features.

I'm thinking that I could make a second listbox and take items that 'passes' the search, to there. But this seams like a lot of work.

What's the easiest way?
0
Comment
Question by:Stream12
[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 9

Accepted Solution

by:
mocarts earned 375 total points
ID: 8187394
you can keep all your items in TStringList and when searched, search in it and use ListBox to display results

var
  data: TStringList;
 
// returns search result in TStringList;
procedure PerformSearch(const Phrase: string; st: TStrings);
var i: integer;
begin
  st.BeginUpdate;
  try
    st.Clear;
    for i := o to data.Count -1 do
      if .. then
        st.Add(data[i]);
  finally
    st.EndUpdate;
  end;
end;

// without timer
procedure TForm1.Edit1Change(Sender: TObject);
begin
  PerformSearch(Edit1.Text, ListBox1.Items);
end;

// with timer
procedure TForm1.Edit1Change(Sender: TObject);
begin
  Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  PerformSearch(Edit1.Text, ListBox1.Items);
end;

wbr, mo.
0
 

Expert Comment

by:rayek007
ID: 8187837
You could try this "memo1.lines.clear;" every time you press a key in the edit or what you are using for the searched word, and the rest of your code.
0
 
LVL 4

Expert Comment

by:nestorua
ID: 8189450
HI,
If you wish to use only ListBox then the most natural and resonable way - to use TStringList and filter it then showing the filtered result in ListBox (as it's proposed above by mocarts).
If not - then you can use TClientdataSet and TDBGrid, they are lovely do that filtering you need and show result in different ways.
Sincerely,
Nestorua.
0
 

Author Comment

by:Stream12
ID: 8293204
I had to change some things, but your anwser did help. Thanks.
0

Featured Post

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.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

752 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