BookmarkSubscribe
Choose Language Hide Translation Bar
djhanson
Community Trekker

Listbox - control font color on a single item?

Is there any creative way to control the font color on a particular item within a listbox?  I know how to send font color to the entire list within a listbox, but I was curious if this could be applied to a single item in the list for example.

thx, DJ

0 Kudos
1 REPLY 1
Highlighted
pmroz
Super User

Re: Listbox - control font color on a single item?

You can get different colors if you use col boxes inside a tablebox.  Looks similar - here's an example.

n1_list = [1, 2, 3, 4];
c1_list = {"XXX", "YYY", "ZZZ", "WWW"};
tb_list = {};

cb = col box("String1");
for (i = 1, i <= nitems(c1_list), i++,
	tb_list[i] = text box(c1_list[i]);
	cb << append(tb_list[i]);
);

// Change the color of the third item
tb_list[3] << font color("Red");

nw = new window("Test Color Listbox",
	tb = table box(
		number col box("Index", n1_list),
		cb
	)
);

tb << Set Selectable Rows(1);

tb << set row change function(
	Function( {this},

		row_list = this << get selected rows;
		if (nrows(row_list) > 0,
			one_row = row_list[1];
			show(one_row, c1_list[one_row]);
		);
	);
);