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

3 ビュー (過去 30 日間)
theblueeyeswhitedragon
theblueeyeswhitedragon 2018 年 4 月 10 日
回答済み: Walter Roberson 2018 年 4 月 10 日
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

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 10 日
Change
addstring = {get(texth, 'String')};
to
addstring = get(texth, 'String');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by