?
Solved

ListBox Search and Replace

Posted on 2003-02-23
2
Medium Priority
?
159 Views
Last Modified: 2010-04-04
Hello, I need a way to search for an item in a listbox(s) or listbox and replace it through an inputbox, i can't seem to find an example anywhere, if anyone has this solution or somewhere can you please follow up.

Thanks a lot.
-fluked
0
Comment
Question by:fluked
[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 27

Expert Comment

by:kretzschmar
ID: 8006562
procedure ReplaceListBoxEntry(AListBox : TListBox; OldEntry, NewEntry : String);
var i : Integer;
begin
  i := AListBox.Items.IndexOf(OldEntry);
  If i > 0 then
    AListBox.Items[i] := NewEntry;
end;

meikl ;-)
0
 
LVL 4

Accepted Solution

by:
cjm30305 earned 80 total points
ID: 8019062
public
  { public declarations }
 procedure SearchAndReplace(Str: String);

procedure TForm1.Button1Click(Sender: TObject);
var
 SearchText: String;
begin
  if InputQuery('Input Box', 'Text to search for:', SearchText) then
   SearchAndReplace(SearchText);
end;

procedure TForm1.SearchAndReplace(Str: String);
var
 MyString: String;
 i : Integer;
begin
 if InputQuery('Input Box', 'Text to replace with:', MyString) then
  begin
   for i := 0 to ListBox1.Items.Count - 1 do
    begin
     if Str = ListBox1.Items.Strings[i] then
      ListBox1.Items.Strings[i] := MyString;
    end;
  end;
end;
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

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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