Dev GridControl double-click row event

Source: Internet
Author: User

This article from: http://www.cnblogs.com/xiaofengfeng/archive/2011/09/15/2177625.html

 

Today, the gridcontrol control is used, and a double-click event of the gridview is required, because the Message is displayed only when the row is double-clicked. I didn't implement it with the Double_Click of the gridview. Later I thought of MouseDown, first, you still need to set gridview1.OptionsBehavior. set EditablefalseBelow is the code:
  
  Skelta BPM. NET (World's first. NET workflow engine) Visual WebGui (perfect user interface solution)
  List & Label (Chart report generation control) DXperience Uni Premium platinum edition (exclusive to huidu)
  
       // Double-click the row to display the nodeDetail information.
        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)
            
                // Determine whether the cursor is within the row range
                if (hInfo.InRow) 
                
                    // Obtain the information of the selected row
                    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(); 
                    
                
            
        }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.