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

2 views (last 30 days)
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

Accepted Answer

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

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!