Line break in "question dialog"

조회 수: 84 (최근 30일)
Jorge
Jorge 2011년 1월 31일
댓글: Axel 2023년 3월 23일
Hi. I'm trying to introduce a line break in question dialog box in the qstring. I've used '\n' but it gives me error. Also I've used the three points (...) but it happened the same. Is the line break accepted in the question dialog box? Thanks

답변 (4개)

Martijn
Martijn 2011년 1월 31일
Functions like INPUTDLG and MSGBOX do not interpret '\n' characters; SPRINTF does however. So using SPRINTF should do the trick:
msgbox(sprintf('Line 1\nLine 2'))

Doug Eastman
Doug Eastman 2011년 1월 31일
Another approach is to use a cell array:
questdlg({'Text on line 1','Text on line 2'})

Paulo Silva
Paulo Silva 2011년 1월 31일
questdlg(['Text on line 1' sprintf('\n') 'Text on line 2'])

Axel Montano
Axel Montano 2020년 5월 9일
편집: Axel Montano 2020년 5월 9일
'String',sprintf('Line 1\nLine 2'));
This is what I used when running a dialog box.
Here is the whole code to make it easier for anyone wanting to play around with a dialog box.
Goodluck!
d = dialog('Position',[1000 600 400 300],'Name','Written by: ME!');
txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[100 200 210 40],...
'String',sprintf('Line 1\nLine 2\nLine 3'));
btn = uicontrol('Parent',d,...
'Position',[150 20 100 40],...
'String','Close dialog box',...
'Callback','delete(gcf)');
  댓글 수: 1
Axel
Axel 2023년 3월 23일
This is an old post, however for any future reference. The newline command can be used to perform this task properly.
"You selected to solve a single load transmission line problem." newline "test line of text"

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by