请问通过单击datagrid中某一单元格时,如何能获取单元格的所在行.

ywbair 2003-07-31 03:15:35
请问通过单击datagrid中某一单元格时,如何能获取单元格的所在行.
...全文
31 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ywbair 2003-07-31
  • 打赏
  • 举报
回复
谢谢,问题已解决,不过是通过dataGrid自身的属性。但你提供的选中的代码也是很有用的 :)
saucer 2003-07-31
  • 打赏
  • 举报
回复
bookmark this Windows.Forms FAQ site:
http://www.syncfusion.com/FAQ/WinForms/default.asp

see (hti.Row is the row number):

5.7 How can I select the entire row when the user clicks on a cell in the row?
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q689q


private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

{

System.Drawing.Point pt = new Point(e.X, e.Y);

DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);

if(hti.Type == DataGrid.HitTestType.Cell)

{

dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);

dataGrid1.Select(hti.Row);

}

}


110,535

社区成员

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

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

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