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

7 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Abr. de 2018
Change
addstring = {get(texth, 'String')};
to
addstring = get(texth, 'String');

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by