uicontrol オブジェクトで複数行​の文字列に対応するに​はどうすればよいです​か。

13 views (last 30 days)
MathWorks Support Team
MathWorks Support Team on 29 Jun 2009
uicontrol オブジェクトで複数行の文字列に対応するにはどうすればよいですか。

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Jun 2009
次のスタイルのuicontrol オブジェクトでは、複数行の文字列に対応しています。
(1) Edit
(2) Text
(3) Popupmenu
(4) Listbox
Edit と Text では、改行コード(\n)で行間を区切った一連の文字列を作成し、'String'プロパティに設定します。
また、Edit では、複数行の表示に対応するため、'Max'プロパティと'Min'プロパティの値の差が1より大きくなるように値を設定します。
Popupmenu と Listbox では、セル配列、もしくは、縦棒(|)で区切った文字列を'string'プロパティに設定します。
サンプルコードを下記に示します。
A={'red','blue','yellow'};
str1 = sprintf('%s\n%s\n%s',A{1,1},A{1,2},A{1,3});
h= uicontrol('Style','Edit','String',str1,'Position',[10 200 75 100],'Max',2);
h= uicontrol('Style','Text','String',str1,'Position',[10 80 75 100]);
h= uicontrol('Style','Popupmenu','String',A,'Position',[150 200 75 100]);
h= uicontrol('Style','Listbox','String',A,'Position',[150 80 75 100]);

More Answers (0)

Categories

Find more on 基本的な設定 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!