Converting string to enum

In regard to the topmost answer, using a bunch of if’s or a switch in order to convert a string to a number and then back to an enum is a really bad and unoptimized way of doing it.



enum EMyEnum
{
    // ...
};

FString fsComboBoxValue = TEXT("1"); // Your combobox value

int32 iEnumValue = FCString::Atoi(*fsComboBoxValue);

EMyEnum myEnum = EMyEnum((uint8)iEnumValue);


If FCString is undefined you might need to include: Runtime/Core/Public/Misc/CString.h

3 Likes