Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ListBox Search and Replace

Posted on 2003-02-23
2
Medium Priority
?
166 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

578 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