Selection color in uicontrol listbox
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Trevor Harris
am 6 Aug. 2018
Kommentiert: Joris Lambrecht
am 2 Jun. 2020
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 Kommentar
Adam Danz
am 6 Aug. 2018
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.
Akzeptierte Antwort
Monica Roberts
am 8 Aug. 2018
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
0 Kommentare
Weitere Antworten (1)
Keqin Xu
am 31 Okt. 2019
Trouble is, when there are "<" in the string, the "<" are missing in the listbox!
Any ideas to fix it? Thanks!
1 Kommentar
Joris Lambrecht
am 2 Jun. 2020
I use the following little function:
function htmlStr = formatHTML(str)
% FORMATHTML converts < and > to HTML codes
htmlStr = strrep(str, '<', '<');
htmlStr = strrep(htmlStr, '>', '>');
end
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!