列表视图复选框C# [英] Listview checkbox C#

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

问题描述

Good affertoon

我正在尝试将CheckBox放在我列表中的某些列上,最不幸的是我没有得到它。我可以插入的唯一列在第一列,但我需要将其插入其他列。它有办法吗?





我尝试过:



好的affertoon 
< pre>我试图将CheckBox放在我列表中的某些列上,最不幸的是我没有得到它。我可以插入的唯一列在第一列,但我需要将其插入其他列。有没有办法做到这一点?

解决方案

我建​​议使用带有布尔属性的类或 List< ;> 类的 BindingSource 用于 DataGridView ,当您使用:< pre lang =c#> dataGridView.AutoGenerateColumns = true ;

布尔值将自动转换为复选框。

这将需要一些研究,但对您以后的项目有益,并可能导致IT行业的辉煌事业。另请参阅:详细数据绑定教程 [ ^ ]



有关 SQL Server 数据库的示例,请参阅:如何使用datagridview查看列表中的数据表 [ ^ ]


< blockquote>您可能还想考虑使用 ObjectListView [ ^ ]。 它是香草 ListView 的mondo酷替代品。



/ ravi


Good affertoon

I'm trying to put CheckBox on some columns in my List most unfortunately I'm not getting it. The only column I can insert is in the first column, but I need to insert it in other columns. Does it have a way to do this?



What I have tried:

Good affertoon 
<pre>I'm trying to put CheckBox on some columns in my List most unfortunately I'm not getting it. The only column I can insert is in the first column, but I need to insert it in other columns. Does it have a way to do this?

解决方案

I would suggest using a Class with boolean properties or List<> of classes as a BindingSource for your DataGridView, when you use:

dataGridView.AutoGenerateColumns = true;

the boolean values will automatically be converted to checkboxes.
This will take some study, but will be of benefit to your later projects and maybe result in a shiny career in the IT industry. Also see: A Detailed Data Binding Tutorial[^]

For an example with an SQL Server database, see: How to view the datatable in list using datagridview[^]


You may also want to consider using ObjectListView[^].  It's a mondo cool replacement for the vanilla ListView.

/ravi


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

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