필터 지우기
필터 지우기

Selection color in uicontrol listbox

조회 수: 5 (최근 30일)
Trevor Harris
Trevor Harris 2018년 8월 6일
댓글: Joris Lambrecht 2020년 6월 2일
Hey all!
I'm wondering if there is a way to control the highlight selection color (currently blue) in a list box? See attached example.
TIA!
Trevor
  댓글 수: 1
Adam Danz
Adam Danz 2018년 8월 6일
You could change the background color of individulal rows (see this ) but I don't know of a way to change the selection highlight color.

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

채택된 답변

Monica Roberts
Monica Roberts 2018년 8월 8일
There is no object property you can change to alter the highlight selection color.
As a workaround, in your list selection callback, you can deselect the item to remove the highlight, and change the background color using the HTML method Adam linked to. The following answers page provides a good example of how to change the text colors in individual rows, you can modify it to change the "bgcolor" instead of "color" (in the line pre = ...), which will "highlight" that list item.
https://www.mathworks.com/matlabcentral/answers/153064-change-color-of-each-individual-string-in-a-listbox

추가 답변 (1개)

Keqin Xu
Keqin Xu 2019년 10월 31일
Trouble is, when there are "<" in the string, the "<" are missing in the listbox!
Any ideas to fix it? Thanks!
  댓글 수: 1
Joris Lambrecht
Joris Lambrecht 2020년 6월 2일
I use the following little function:
function htmlStr = formatHTML(str)
% FORMATHTML converts < and > to HTML codes
htmlStr = strrep(str, '<', '&#60');
htmlStr = strrep(htmlStr, '>', '&#62');
end

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by