1. Technology

Delphi Enum to String

By

Here's how to display the string represention of a Delphi enum type at runtime.

~~~~~~~~~~~~~~~~~~~~~~~~~
{
Suppose enum:

TProgrammerType = (tpDelphi, tpVisualC, tpVB, tpJava) ;
}

uses TypInfo;
var s: string;
s := GetEnumName(TypeInfo(TProgrammerType),
                  integer(tpDelphi)) ;

//s='tpDelphi'

~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to install an INF file using Delphi
« Using an object with no reference variable

©2014 About.com. All rights reserved.