Fill a listbox with the text of a set of enumerations

4 ビュー (過去 30 日間)
John Petersen
John Petersen 2015 年 12 月 14 日
回答済み: Walter Roberson 2015 年 12 月 14 日
I have a listbox in a GUI that I want to populate using enumerations. My class of enumerations might be something like
myenum.circle
myenum.square
myenum.triangle
and I want the listbox to show
circle
square
triangle
as options to select. Is there a way to use the enumeration labels in the listbox? The reason for doing this is so that if I edit the enum file, it will automatically change the next time I run the GUI. I have defined the enums in a file like this:|
classdef myenum < int32
enumeration
Circle (0)
Line (1)
Square (2)
end
methods(Static)
function y=addClassNameToEnumNames()
y=true;
end
end
end

採用された回答

Walter Roberson
Walter Roberson 2015 年 12 月 14 日
[~,membernames] = enumeration('myenum');
set(handles.listbox1, 'String', membernames);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by