DevExpress XtraGrid 行雙擊事件的處理


要響應GridView的單擊或者雙擊事件,要設置GridView的OptionsBehavior.Editable=false。如果為true,它是不會響應這這兩個事件的。 它本的的機制就是這樣,祥細說明請看: The   DoubleClick   event   occurs   when   the   end   user   double-clicks   within   a   view.   The   DoubleClick   event   does   not   occur   if   an   in-place   editor   is   activated   as   a   result   of   double-clicking   as   well   as   when   double-clicking   within   the   GridControl.EmbeddedNavigator.

 

       //雙擊行彈出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();
}
}
}
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM