DataGridView 按钮事件...

egpscar 2006-03-07 11:03:08
按钮列
DataGridView 提供的一种列是 DataGridViewButtonColumn,这种列在每一项旁边显示一个按钮。您可以响应此按钮的单击事件,并使用它启动其他操作或显示新的表单。


图 3 显示了包含新列的网格。以下代码会对任何行中的按钮单击事件做出反应,并显示相应的记录信息:

Private Sub DataGridView1_CellClick( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms. _
DataGridViewCellEventArgs) _
Handles DataGridView1.CellClick

If DataGridView1.Columns(e.ColumnIndex).Name = _
"Details" Then
MessageBox.Show("You picked " & _
DataGridView1.Rows(e.RowIndex). _
Cells("CustomerID").Value)
End If
End Sub



能帮我翻译(C#)一下上面的代码吗? 我对VB实在是不懂...
...全文
841 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
egpscar 2006-03-08
  • 打赏
  • 举报
回复
DataGridView1_CellClick
egpscar 2006-03-07
  • 打赏
  • 举报
回复
郁闷~~没反应.
superfishmanweb 2006-03-07
  • 打赏
  • 举报
回复
Private Sub DataGridView1_CellClick(object sender, System.Windows.Forms.
DataGridViewCellEventArgs e)
{
If (DataGridView1.Columns(e.ColumnIndex).Name == "Details")
{
MessageBox.Show("You picked "+DataGridView1.Rows(e.RowIndex).Cells("CustomerID").Value);
}
}

superfishmanweb 2006-03-07
  • 打赏
  • 举报
回复
If (DataGridView1.Columns(e.ColumnIndex).Name == "Details")
{
MessageBox.Show("You picked "+DataGridView1.Rows(e.RowIndex).Cells("CustomerID").Value)
}
egpscar 2006-03-07
  • 打赏
  • 举报
回复
UP
alost 2006-03-07
  • 打赏
  • 举报
回复
当然没有反应了,C#没有没有CellClick事件

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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