zoukankan      html  css  js  c++  java
  • dev GridControl双击行事件

    今天用到了gridcontrol这个控件,要求写一个gridview的双击事件,因为想要的效果是只双击行才出Message,用gridview的Double_Click我没实现,后来想到MouseDown,一试,很简单,首先,仍旧需要将gridview1.OptionsBehavior.Editable设为false,下面是代码:   

           //双击行弹出nodeDetail信息

    private void gridView1_MouseDown(object sender, MouseEventArgs e)
           {
               DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hInfo = gridView1.CalcHitInfo(new Point(e.X,e.Y));
               if (e.Button == MouseButtons.Left && e.Clicks == 2)
               {
                   //判?断?光?标?是?否?在?行?范?围?内?
                   if (hInfo.InRow)
                   {
                       //取?得?选?定?行?信?息?
                       string nodeName = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "nodeName").ToString();
                       //string nodeName = gridView1.GetRowCellValue(gridView1.GetSelectedRows()[0], "nodeName").ToString();
                       string sql = "select nodeDetail from treelist where nodeName = '" + nodeName + "'";
                       SqlCommand comm = new SqlCommand(sql, conn);
                       try
                       {
                           conn.Open();
                           MessageBox.Show(comm.ExecuteScalar().ToString(), "Detail");
                       }
                       catch (Exception ex)
                       {
                           MessageBox.Show(ex.Message, "Error");
                       }
                       finally
                       {
                           conn.Close();
                       }
                   }
               }
           }
  • 相关阅读:
    cf C. Vasya and Robot
    zoj 3805 Machine
    cf B. Vasya and Public Transport
    cf D. Queue
    cf C. Find Maximum
    cf B. Two Heaps
    cf C. Jeff and Rounding
    cf B. Jeff and Periods
    cf A. Jeff and Digits
    I Think I Need a Houseboat
  • 原文地址:https://www.cnblogs.com/hdl217/p/2044877.html
Copyright © 2011-2022 走看看