How to use set to change a property of a uicontrol?

2 Ansichten (letzte 30 Tage)
function [] = script2()
fig = figure('units','pixels','position',[300 300 500 400], 'menubar','none','name','GUI_3','numbertitle','off','resize','off');
listh = uicontrol('style', 'list', 'unit', 'normalized', 'position', [0.25, 0.4, 0.5, 0.5], 'string', {'one';'two';'three';'four'}, 'FontSize', 14);
pushbuttonh = uicontrol('style', 'pushbutton', 'unit', 'normalized', 'position', [0.375, 0.125, 0.2, 0.1], 'FontWeight', 'bold', 'string', 'Submit', 'FontSize', 14, 'Callback', @pushbuttonh_Callback);
texth = uicontrol('style', 'edit', 'unit', 'normalized', 'position', [0.35, 0.25, 0.275, 0.075], 'String', 'Enter New String', 'FontSize', 12.5);
function pushbuttonh_Callback(source, value)
oldstring = get(listh, 'String');
addstring = {get(texth, 'String')};
oldstring{5} = addstring;
set(listh, 'String', oldstring);
end
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Apr. 2018
Change
addstring = {get(texth, 'String')};
to
addstring = get(texth, 'String');

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by