Pre-populating List Controls

Two of the controls on the download request form are DropDownList controls to allow the user to select his country and state/province. Obviously, we’ll need to populate these controls. The method by which this is currently done is to read these values from a file containing name/value pairs. So, for instance, a states.txt file contains data such as

AL=Alabama
AK=Alaska
AB=Alberta
AS=American Samoa
AZ=Arizona
AR=Arkansas
BC=British Columbia
CA=California
CO=Colorado

Likewise, a file, countries.txt, contains similar data but with countries. Listing 26.2 is a function that reads these files and populates the DropDownList that is passed as a parameter with the contents of the file whose name is also passed as a parameter. ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.