ProgramThe ListBox entries must be color-differentiated. Although the <option> element does not have a ready-made forecolor, there is a style and the style contains color.
The attributes. Add method is available in the items set of ListBox, followed by two parameters. Therefore, it can be written
Listbox1.items [I]. Attributes. Add ("style", "color: Blue ;");
I thought the problem was solved, but later I found that there was only one color at a time.
Originally, this is the difference between the winform program and the web program:
In winform mode, my program processing principle is: When you click another entry, set the color of the previous entry. After the setting is complete, "If noCodeIndicates that the color will not be cleared if it is to be cleared ".
In the web program, because each web page is refreshed again, "If no code indicates that you want to set the color, it will not be set ".
Therefore, I have checked all the times now and need to set it.
However, I later found that my detection code was placed in the event of entry change. As a result, after other things were triggered, the color of the item was all restored to the original color. at this time, I thought of the suggestions I found in Google. "attributes is usually used. add "is put in page_load, which makes sense.