Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Use Ini With ListBox1

Posted on 1998-12-01
1
Medium Priority
?
256 Views
Last Modified: 2010-04-04
Hello!!!
I have a ini file and like to put all sections into listbox1
and under each section i like to add to listbox2
example of my ini
[SOFTSEEK]
URL=http://www.softseek.com
[DOWNLOAD.COM]
URL=http://www.download.com

E.g
I like to add [SOFTSEEK] into listbox1 and it's url to listbox2
URL=? into listbox2
Can i do this on event "OnCreate" of the form
Do you have a code..Thanks.....
0
Comment
Question by:mummi
1 Comment
 
LVL 3

Accepted Solution

by:
williams2 earned 100 total points
ID: 1348753
I think I've got it, try this

The INI file should look like this:
[URL0]
name=SOFTSEEK
URL=http://www.softseek.com
[URL1]
name=DOWNLOAD.COM
URL=http://www.download.com


The save it as 'urls.ini' in your project folder. Then the rest is cut'n'paste:

procedure TForm1.FormCreate(Sender: TObject);
var
  IniFile: TIniFile;
  i: Integer;
  Section,FName,FURL: String;
begin
  IniFile:= TIniFile.Create(ExtractFilePath(ParamStr(0))+'Urls.ini');
  i:= 0;
  Repeat
    Section:= 'URL'+IntToStr(i);
    FURL:= IniFile.ReadString(section,'URL','');
    FName:= IniFile.ReadString(section,'Name','');
    If FName<>'' then
    Begin
      ListBox1.Items.Add(FName);
      ListBox2.Items.Add(FURL);
    End;
    Inc(i);
  Until FName='';

end;

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

971 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