C#中DataGrid控件如何接鼠标收双击事件 最近,用C# C/S方式windows编程,本人是想利用DataGrid控件检索数据,然后再又击行后调出详细信息,但不知DataGrid如何接收鼠标收双击事件,请赐教。 本人是C#的初学者。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道这个是否对你有帮助,这个就是通过代码去 DataGrid第一列 单元格中的值,然后这里面的值就是数据库中的ID 点他后,弹出详细信息的窗口。然后在弹出窗口的事件中显示当前数据库ID的详细信息private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { try { cellValue = this.dataGrid1[this.dataGrid1.CurrentRowIndex,0];// System.Drawing.Point pt = new Point(e.X, e.Y); // DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(pt); // dataGrid1.CurrentCell = new DataGridCell(hti.Row, 1); // dataGrid1.Select(hti.Row); // cellValue = dataGrid1[hti.Row, 0]; // MessageBox.Show(cellValue.ToString());//////// frmbase_cfrm = new kehu_frmbase_cfrm(this,cellValue.ToString());// this.frmbase_cfrm.Show();// this.tmp = 2; } catch (System.Exception myEr) { MessageBox.Show(myEr.ToString()); } } http://community.csdn.net/Expert/topic/3940/3940751.xml?temp=.6154444 C/S的我不太熟,但看了一下,datagrid是有DoubleClick事件的你是想看事件的原理的吗? System.Drawing.Point pt = new Point(e.X, e.Y); DataGrid.HitTestInfo hti = this.dgResult.HitTest(pt); if(hti.Type == DataGrid.HitTestType.Cell) { this.dgResult.CurrentCell = new DataGridCell(hti.Row, hti.Column); this.dgResult.Select(hti.Row); }在mouse_up里面加入上面的这些,可以保证能够触发doubleclick,而不是选中行的内容。 控件配置文件无效?! 难道控件把配置文件打包自己吃了! 水晶报表的一个问题 一个c#菜鸟的问题,关于FileStream,望高手回答~~~ 【急】大家帮帮忙,找一个c# 时间线控件,如图: remoting传值问题 自己搞了个网站,大家看看? C#中的父子窗口如何实现阿? gridView 设置列宽 怎样将DataGrid中的数据直接打印和另存为文本格式? Help!!!如何將TextBox1中的文本轉化成數字參于運算呀! 应用软件的升级包应该怎样做?? 一个非常简单的画线程序,为何出现“未将对象引用设置到对象实例”?
{
try
{
cellValue = this.dataGrid1[this.dataGrid1.CurrentRowIndex,0];
// System.Drawing.Point pt = new Point(e.X, e.Y);
// DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(pt);
// dataGrid1.CurrentCell = new DataGridCell(hti.Row, 1);
// dataGrid1.Select(hti.Row);
// cellValue = dataGrid1[hti.Row, 0];
// MessageBox.Show(cellValue.ToString());
//////
// frmbase_cfrm = new kehu_frmbase_cfrm(this,cellValue.ToString());
// this.frmbase_cfrm.Show();
// this.tmp = 2;
}
catch (System.Exception myEr)
{
MessageBox.Show(myEr.ToString());
}
}
你是想看事件的原理的吗?
DataGrid.HitTestInfo hti = this.dgResult.HitTest(pt);
if(hti.Type == DataGrid.HitTestType.Cell)
{
this.dgResult.CurrentCell = new DataGridCell(hti.Row, hti.Column);
this.dgResult.Select(hti.Row);
}
在mouse_up里面加入上面的这些,可以保证能够触发doubleclick,而不是选中行的内容。