在应用的CheckBoxList样式ListItems的 [英] Applying Styles To ListItems in CheckBoxList

查看:153
本文介绍了在应用的CheckBoxList样式ListItems的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何样式应用到的CheckBoxList ListItems的。不像其他控件,如在那里你可以指定转发< ItemStyle方式> ,你似乎无法指定样式为每个单独的控制

How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify <ItemStyle>, you can't seem to specify a style for each individual control.

是否有某种工作周围的?

Is there some sort of work around?

推荐答案

您可以通过编程属性添加到ListItems的如下:

You can add Attributes to ListItems programmatically as follows.

假设你有一个的CheckBoxList和您要添加ListItems的。您可以沿途添加属性。

Say you've got a CheckBoxList and you are adding ListItems. You can add Attributes along the way.

ListItem li = new ListItem("Richard Byrd", "11");
li.Selected = false;
li.Attributes.Add("Style", "color: red;");
CheckBoxList1.Items.Add(li);

这会使列表项文本显示为红色的颜色。实验和乐趣。

This will make the color of the listitem text red. Experiment and have fun.

这篇关于在应用的CheckBoxList样式ListItems的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆