在Datagridview的单元格中显示带有复选框的文本 [英] Display text with checkbox in cell in Datagridview

查看:497
本文介绍了在Datagridview的单元格中显示带有复选框的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.我需要在Windows窗体应用程序的datagridview的复选框列中显示带有复选框的文本.

Hi there. I need to display text with a checkbox in a checkbox column in a datagridview in a windows forms application.

推荐答案

签出:http://social.msdn.microsoft.com/forums/zh-CN/winformsdatacontrols /thread/8be37fae-eb75-4194-9534-eb45562daa99/ [ http://www.murrayhilltech.com/articles/articles.aspx?key=7 [ ^ ]
Check this out: http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/8be37fae-eb75-4194-9534-eb45562daa99/[^]

And this: http://www.murrayhilltech.com/articles/articles.aspx?key=7[^]


你好,
如果您想要快速解决方案,对于少量的电池,
您可以这样做:

1.使用ColumnType DataGridViewCheckBoxColumn创建一列,
该列外壳中的单元格为复选框.还应使其与复选框一样小.
此列的标题文本应为空字符串(无).

2.使用ColumnType dataGridViewTextBoxColumn创建第二列,其中所有
单元格应为文本框.该列的标题文本应为您的文本
想要第一列.

3.使用DataGridView(column,row).Value ="text";你
可以在该列的每个单元格中设置初始值text,
除非您要创建的程序太复杂,单元太多.

4.在属性面板中使用不同的DataGridViewCellStyles,您可以制作
它看起来像是一个带有复选框和文本的单元格.也许看起来
更好.

另一种解决方案是对当前的DataGridViewCheckBoxColumn类进行重新编程,并使自己具有在同一单元格中具有复选框和文本的可能性.
对我来说,它太复杂了,结果未知.

很好,
佩里克(Peric Zeljko)
< removed> @ yahoo.com
Hello,
if you want quick solution,for small amount of cell,
you could do this :

1. Make one column with ColumnType DataGridViewCheckBoxColumn ,
cells in that column shell be check boxes.Also make it small as the check box.
Header text for this column shall be empty string (nothing).

2. Make second column with ColumnType dataGridViewTextBoxColumn where all the
cells shall be text boxes. Header text of that column shall be the text you
want for the first column.

3. Using DataGridView(column,row).Value = "text"; you
can set the initial value , text, in every single cell in that column ,
except in case if you are creating too complex program, with many cells.

4. Using different DataGridViewCellStyles from properties panel , you can make
that it looks like it is one cell with check box and text.Perhaps it looks
even better.

Other solution is to reprogram current DataGridViewCheckBoxColumn class and make your own with that possibility to have check box and text in the same cell.
For me it is too complicated and with unknown results.

All well,
Peric Zeljko
<removed>@yahoo.com


这篇关于在Datagridview的单元格中显示带有复选框的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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