Changing color of a string in listbox - MATLAB GUI
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a list of names in a listbox. What I would like to do is have a certain selected name change color, from red to green, when I click a button.
Thank you
댓글 수: 0
채택된 답변
Walter Roberson
2012년 6월 14일
Don't add the name directly: add the HTML-ized version of the name.
htmlname = sprintf('<HTML><BODY bgcolor="%s">%s', 'red', ThisEntryName);
And in the callback:
namestr = cellstr(get(hObject, 'String'));
validx = get(hObject, 'Value');
newstr = regexprep(namestr{validx}, '"red"','"green"');
namestr{validx} = newstr;
set(hObject, 'String', namestr);
댓글 수: 1
추가 답변 (6개)
Tom
2012년 6월 14일
You can do it with html- see http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/
댓글 수: 0
Vincent I
2012년 6월 14일
댓글 수: 1
Dr. Seis
2012년 6월 14일
What you are generally describing above should work with HTML... can you post a few pictures of what you envision? Or can you post the cell-string you are using to apply to the listbox... there might be a formatting issue that is preventing it from working.
Vincent I
2012년 6월 18일
댓글 수: 1
Walter Roberson
2012년 6월 18일
namestr(validx) = []; %delete it from where it was
namestr = [ {newstr}; namestr ];
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!