ListBox multiple item, how to control a few item font color ? Such as the first 3,6 item font color to red.
Note: Not selected item.
------ Solution ----------------------------- ---------------
replaced listview
------ For reference only ----------------- ----------------------
protected void Page_Load(object sender, EventArgs e)
{
SetColor();
}
private void SetColor()
{
ListBox1.Items.Add("aaaa");
ListBox1.Items.Add("bbbb");
ListBox1.Items.Add("dd");
ListBox1.Items.Add("ggggggg");
ListBox1.Items.Add("asdfasdf");
ListBox1.Items.Add("uluiuil");
ListBox1.Items[3].Attributes.CssStyle["background-color"] = "red;";
}
------ For reference only ---------- -----------------------------
ListBox1.Items [3]. Attributes.CssStyle ["background-color"] = "red;";
this code where they come from , is a form program , without this code .
------ For reference only -------------------------------------- -
set the font , background color can be , the purpose is to allow a certain item looks different from the other item .
------ For reference only -------------------------------------- -
listview so hard to use it .
没有评论:
发表评论