Hiya All
Been thinking about this problem with case statements and came across
GetEnumName in the RTTI calls
Surprisingly Delphi includes the 'names' of enumerated types in the program
(I always thought they were symbolic and therefore
removed by the compiler)
So Try This!
What would be nice though is
1/ TString having a method to load value from an enurmerated type
2/ The compiler does allow much in the way of Enum names 'C++' was
disallowed and 'Left'
caused problems in the case statement - both these problems could be
addressed in 1/ by removing a leading character
or using a regex type expression to include illegal chars
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, TypInfo, mwkRadioGroup;
type
TForm1 = class(TForm)
mwkRadioGroup1: TmwkRadioGroup;
procedure FormCreate(Sender: TObject);
procedure mwkRadioGroup1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
type
TRadioButtons = (VB,Delphi,C,Java);
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
for i := Ord(Low(TRadioButtons)) to Ord(High(TRadioButtons)) do
mwkRadioGroup1.Items.Add(r(TypeInfo(TRadioButtons),i));
end;
procedure TForm1.mwkRadioGroup1Click(Sender: TObject);
begin
case TRadioButtons(mwkRadioGroup1.ItemIndex) of
VB: ShowMessage('I choose VB as best language');
Delphi:ShowMessage('I choose Delphi as best language');
C: ShowMessage('I choose C as best language');
Java: ShowMessage('I choose Java as best language');
end;
end;
end.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz