怎么在winform得到datagrid里的checkbox选中的行的数据

dancun 2007-09-18 04:53:36
在datagrid里加了checkbox然后要得到这行的数据,把这些数据放进int1和int2两个参数里。我该怎么做?

我得到选中行的语句是:Dim rows as datarow() = ds1.tables("table1").select("Bool = 1")

请问我接下来该怎么写啊?ds1是我dataset的名字。。
...全文
158 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qinboody 2007-09-19
  • 打赏
  • 举报
回复
For i = 0 To Me.DataGridView1.Rows.Count - 1

checkCell = CType(DataGridView1.Rows.Item(i).Cells(0), DataGridViewCheckBoxCell)
isChecked = CType(checkCell.Value, [Boolean])
If isChecked = True Then
int1=
int2=
......
end if
新鲜鱼排 2007-09-19
  • 打赏
  • 举报
回复
5.80 How can I get a CheckBox column in a DataGrid to react to the first click?
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q945q
[VB.Net}

Private myCheckBoxCol As Integer = 9 'my checkbox column

Private Sub DataGrid2_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles DataGrid2.MouseUp

Dim hti As DataGrid.HitTestInfo = Me.dataGrid2.HitTest(e.X, e.Y)

Try

If hti.Type = DataGrid.HitTestType.Cell AndAlso hti.Column = myCheckBoxCol Then

Me.dataGrid2(hti.Row, hti.Column) = Not CBool(Me.dataGrid2(hti.Row, hti.Column))

End If

Catch ex As Exception

MessageBox.Show(ex.ToString())

End Try

End Sub 'dataGrid2_MouseUp


其他参考:
5.33 How do I get the row and column of the current cell in my datagrid?
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q788q

5.27 How can I get the selected text in an active gridcell?
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q827q

5.15 How can I put a checkbox in a column of my DataGrid?
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q754q
dancun 2007-09-19
  • 打赏
  • 举报
回复
谢谢。。偶的居然没人骂我。。哈哈。。。自己昨天晚上解决了。。跟踪下就出结果了

16,554

社区成员

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

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