问题描述:如何以编程方式为XtraGrid的masterDetail grid添加鼠标双击事件?
解决方法:鼠标事件并不是在column-by-column基础上进行处理的。相反,你应该处理GridView的双击事件,并构建一个GridHitInfo对象以确定双击事件在哪一列开始。事件处理程序的sender参数只可以被转换为GridView类型。
[C#]
//Assign a double click handler gridView1.DoubleClick += new EventHandler(gridView1_DoubleClick); private void gridView1_DoubleClick(object sender, EventArgs e) { GridView detailGrid = (sender as GridView); GridHitInfo hitInfo = (detailGrid.CalcHitInfo((e as MouseEventArgs).Location); //Leave if the user didn't double-click in a cell if (hitInfo.InRowCell == false) return; //Leave if the user didn't double-click in the "Person Name" column if (hitInfo.Column != detailGrid.Columns["PersonName"]) return; //Do something else }
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/400.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/400.html