The color of the ListBox entry.

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.