vb.net datagridview里怎么手动添加CHECKBOX列?

螺丝刀2000 2009-03-16 03:36:44
vb.net datagridview里怎么手动添加CHECKBOX列?

谢谢。
...全文
656 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
大文Han 2011-08-18
  • 打赏
  • 举报
回复
'添加checkbox
Dim col As New DataGridViewCheckBoxColumn
col.HeaderText = "选择"
DataGridView1.Columns.Add(col)

'添加button
Dim button As New DataGridViewButtonColumn
button.HeaderText = "明细"
button.Width = 55
DataGridView1.Columns.Add(button)


大文Han 2011-08-18
  • 打赏
  • 举报
回复
'添加checkbox
Dim col As New DataGridViewCheckBoxColumn
col.HeaderText = "选择"
DataGridView1.Columns.Add(col)

'添加button
Dim button As New DataGridViewButtonColumn
button.HeaderText = "明细"
button.Width = 55
DataGridView1.Columns.Add(button)


阿尔泰 2009-10-20
  • 打赏
  • 举报
回复
有帮助
appleller 2009-03-18
  • 打赏
  • 举报
回复
路过学习
xue1234567890 2009-03-18
  • 打赏
  • 举报
回复
Dim dt As New DataTable
Dim dr As DataRow
dr = dt.NewRow
dt.Columns.Add(New DataColumn("选择", GetType(Boolean))) '添加checkbox

DataGridView1.DataSource = dt


这样可以添加checkbox列....
xue1234567890 2009-03-17
  • 打赏
  • 举报
回复

DataGridView1.Columns.Add("", "111") '添加column
DataGridView1.Columns.Add("", "222")

DataGridView1.Rows(0).Cells(0).Value = "columns 111 的 值"

Dim aaa As New CheckBox
aaa.Text = "复选框的文本"
DataGridView1.Controls.Add(aaa) '添加checkbox

这样添加之后位置上不怎么合理, 剩下的看你的了, 大小什么的弄一弄,位置设置一下就可以了..
CloneCenter 2009-03-16
  • 打赏
  • 举报
回复
貌似只能设置 HeaderText ,不能设置复选框的文本。
螺丝刀2000 2009-03-16
  • 打赏
  • 举报
回复
可我添加怎么没有内容?
只有一个CHECKKBOX,我想在CHECKBOX旁边写内容。

谢谢
CloneCenter 2009-03-16
  • 打赏
  • 举报
回复
增加这个类型 DataGridViewCheckBoxColumn 的列就可以了。

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧