码迷,mamicode.com
首页 > 其他好文 > 详细

DEV GridControl双击行事件

时间:2015-07-07 19:04:49      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:

首先,需要将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 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();  
                    }  
                }  
            }  
        } 

 

DEV GridControl双击行事件

标签:

原文地址:http://www.cnblogs.com/porray/p/4627613.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!