彩票走势图

dev GridControl双击行事件

转帖|其它|编辑:郝浩|2011-04-01 13:27:50.000|阅读 2904 次

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

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

  今天用到了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();
                    }
                }
            }
        }

 


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:网络转载

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP