日期:2013-08-24  浏览次数:20486 次

 

在使用Infragistics.Win.UltraWinGrid.UltraGrid时,有时我们想在网格上进行双击操作。比如双击某一行来显示对应的明细数据。但是对于双击事件来说并没有提供对应的行信息。那么我们如何来判断用户双击某一行呢。这里我还是以代码来说明,相信大家都能明白

private void ultraGrid1_DoubleClick(object sender, System.EventArgs e)
  {
   //双击测试,察看当前双击地方是不是一行,如果是则弹出窗体

//获取当前双击点的位置
   Point p=System.Windows.Forms.Cursor.Position; 

//获取当前双击点在网格中所处的位置
   p=this.ultraGrid1.PointToClient(p);

//获取双击点网格控件的元素
   Infragistics.Win.UIElement oUI=this.ultraGrid1.DisplayLayout.UIElement.ElementFromPoint(p);
   if(oUI!=null)
   {

//判断双击点是不是行,也可能是列,如果网格控件选取方式不是设的选中整行的话。
    Infragistics.Win.UltraWinGrid.UltraGridRow oRowUI = oUI.SelectableItem as Infragistics.Win.UltraWinGrid.UltraGridRow;

    if(oRowUI !=null)
    {
        //如果选中的是行,则我们可以通行行的单元格来获取对应的信息

     string s=oRowUI .Cells[0].Value.ToString();

    }
   
   }
   
    
   
  }