How to set MATLAB GUI drop down to be empty be default

6 次查看(过去 30 天)
dd = uidropdown(fig,...
'Position',[30 120 200 22],...
'Items',{'bayesian_optimization','opto_configure_gamma_gp_uncertainty_sampling',...
'grid_search1','grid_search3','electrical_stimulation','cross_entropy','pid_controller',...
'bayesian_optimization','bayesian_optimization2','theta_optimization', 'gamma_maximization', ...
'random_nested_pulse_train', 'opto_configure_gamma_gp_uncertainty_sampling'},...
'Editable','on');
This is my drop down code. By default it goes to the first value on the list which is Bayesian Optimization. Can we have it where it defaults to nothing? And is there way to add functionality to that aswell? Like making every button greyed out until that drop down selected.

采纳的回答

Adam Danz
Adam Danz 2021-4-8
编辑:Adam Danz 2021-4-8
By default, uidropdown uses the first item as the default item but you can also specify the Value property to display another value.
Here I've specified an empty character array to appear when the uidropdown is rendered.
dd = uidropdown(fig,...
'Position',[30 120 200 22],...
'Items',{'bayesian_optimization','opto_configure_gamma_gp_uncertainty_sampling',...
'grid_search1','grid_search3','electrical_stimulation','cross_entropy','pid_controller',...
'bayesian_optimization','bayesian_optimization2','theta_optimization', 'gamma_maximization', ...
'random_nested_pulse_train', 'opto_configure_gamma_gp_uncertainty_sampling'},...
'Editable','on','Value', ''); % <------ specify value
Use the ValueChangedFcn to control the behavior of app components when there is a selection from the dropdown menu. See examples in the documentation.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by