为复选框列表添加空间 [英] adding spaces for checkboxlist

查看:154
本文介绍了为复选框列表添加空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在开发一个有checkboxlists的项目,我想在checkboxlist 项之间添加空格,并且我希望输出如所示

Hello,

I am developing a project in which I am having checkboxlists, I want to add spaces between checkboxlist items, and i want the output like shown

Category1
   Subcategory1
   Subcategory2

Category2
   Subcategory1
   Subcategory2



Category1 Category2 是从数据库填充的checkboxlist ,子类别也是从数据库填充的,正在获得如图所示的输出,



Category1 and Category2 are checkboxlist populating from database, subcategories are also populating from database, am getting output as shown,

Category1
Category2

 Subcategory1(belongs to category1)
 Subcategory2(belongs to category1)

Subcategory1(belongs to category2)
Subcategory2(belongs to category2)



选择Category1后,我希望子类别显示在该类别的下方,并如图所示对齐.请帮助我提供代码.



After selecting Category1, I want subcategories to be shown below that category with alignment as shown. please help me with code.

推荐答案

您正尝试滥用该列表,建议使用特殊格式的字符串用某些对齐方式错误地替换结构.这称为自欺欺人".如果成功,您如何通过文字区分不同级别的类别?

不,如果您有类别和子类别,则这是一个树形结构.如果您具有树结构,请使用树视图.我的猜测是您使用的是System.Web.UI.WebControls(为什么您为什么不正确标记问题中您在说什么呢?有相同的(不合格名称)有不同的类型;这使回答变得棘手吗?为什么问这种方式?!正确的标记将花费额外的几秒钟,而这样做不会浪费我的时间……为什么?!),所以您可以使用System.Web.UI.WebControls.TreeView,它具有属性System.Web.UI.WebControls.TreeView.ShowCheckBoxes以及操作这些标记的方法复选框:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.showcheckboxes.aspx [
You are trying to abuse the list, suggesting wrong replacement of structure with some alignment stuff using specially formatting string. This is called "fooling yourself". If you succeeded, how would you tell categories of different levels, also by text?

No, if you have categories and subcategories, this is a tree structure. If you have a tree structure, use a tree view. My guess is that you are using System.Web.UI.WebControls (why, why don''t you properly tag what are you talking about in your question? there are different types with the same (non-qualifying names); it makes answering tricky? why asking this way?! proper tagging would take a couple of extra seconds, and not doing so wasted my time… why?!), so you could use System.Web.UI.WebControls.TreeView, and it has the property System.Web.UI.WebControls.TreeView.ShowCheckBoxes and the means to manipulate those check boxes:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.showcheckboxes.aspx[^].

—SA


这篇关于为复选框列表添加空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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