How do I list out all of the repetitive rows depending on the number of variables in MATLAB App Designer?
조회 수: 2 (최근 30일)
이전 댓글 표시
I would like to make these row repetitive based on variables that I have. If let's say user input 10 items, there will be 10 rows. Is it possible to do this? The reason why I didn't use the UI.Table is because users are able to choose different item (in dropdown menu) based on preferences.
This would be similar as picture below. Taken a snapshot from another matlab tutorial.
댓글 수: 0
답변 (1개)
Sreeram
2024년 10월 28일
Hi Nurhidayah,
Yes, it is possible to add UI components to the app’s UI Figure based on a variable.
For example, if you want several UI Dropdowns equal to ‘numRows’, one below the other, you add the following code snippet to an appropriate place, such as the button-clicked callback of an Update button. Note that if you want to use variables like ‘dd1’ in another function, consider setting them as Private Properties.
for rowNum=1:numRows
dd1(rowNum) = uidropdown(app.UIFigure, ...
'Position', [10, 40 * (numRows - rowNum + 1), 100, 30], ... % adjust as needed
'Items', {'Option 1', 'Option 2', 'Option 3'}, ...
'Tag', 'Option 1');
% add the other components in appropriate positions
end
You can refer to the documentation on how to add the components programmatically here:
If the added components extend beyond the app’s UI Figure and you want to add them to a scrollable container, consider adding them to a “Panel” instead of the app's UI Figure and setting the setting the “Scrollable” property to ‘on’. More details are available in the documentation for “Panel”:
I hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!