c# devExpress 如何让gridview既可以复制也可以双击跳转

int clicktimes = 0;
DateTime originTime;

private void gridView1_MouseDown(object sender, MouseEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hInfo = gridView1.CalcHitInfo(new Point(e.X, e.Y));
clicktimes += 1;
if (clicktimes == 1)
{
gridView1.OptionsBehavior.Editable = false;
originTime = DateTime.Now; //取当前时间
System.Timers.Timer t = new System.Timers.Timer(600); //实例化Timer类,设置间隔时间为800毫秒;
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
t.AutoReset = false; //设置是执行一次(false)还是一直执行(true);
t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件;

}
if (e.Button == MouseButtons.Left && clicktimes == 2) // 触发双击事件
{
System.TimeSpan st = DateTime.Now.Subtract(originTime);
decimal timeDifference = Convert.ToDecimal(st.TotalMilliseconds.ToString());
if (timeDifference <= 600) // 600 毫秒以内
{
if (hInfo.InRow) // 判断是否在行内
{
if (this.gridControl1.DataSource == null) return;
salesDocCount = this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as SalesDocCount;
Frm_Sales_Invoice frm = new Frm_Sales_Invoice(salesDocCount);
frm.StartPosition = FormStartPosition.CenterScreen;
frm.ShowDialog();
clicktimes = 0;
gridView1.OptionsBehavior.Editable = true;
}
}
else
{
clicktimes = 0;
gridView1.OptionsBehavior.Editable = true;
}
}


}


public void theout(object source, System.Timers.ElapsedEventArgs e)
{
this.gridView1.OptionsBehavior.Editable = true;
}

线程非安全问题参考:

https://docs.microsoft.com/zh-cn/previous-versions/visualstudio/visual-studio-2010/ms171728(v=vs.100)?redirectedfrom=MSDN

c# devExpress 如何让gridview既可以复制也可以双击跳转

上一篇:服务器的windows server 2012 r2 自带的.NET 4.5卸载了,重启服务器黑屏的解决方法


下一篇:Kafka核心API——Connect API