• <small id='Hlubb'></small><noframes id='Hlubb'>

      <i id='Hlubb'><tr id='Hlubb'><dt id='Hlubb'><q id='Hlubb'><span id='Hlubb'><b id='Hlubb'><form id='Hlubb'><ins id='Hlubb'></ins><ul id='Hlubb'></ul><sub id='Hlubb'></sub></form><legend id='Hlubb'></legend><bdo id='Hlubb'><pre id='Hlubb'><center id='Hlubb'></center></pre></bdo></b><th id='Hlubb'></th></span></q></dt></tr></i><div id='Hlubb'><tfoot id='Hlubb'></tfoot><dl id='Hlubb'><fieldset id='Hlubb'></fieldset></dl></div>
        <bdo id='Hlubb'></bdo><ul id='Hlubb'></ul>

        <legend id='Hlubb'><style id='Hlubb'><dir id='Hlubb'><q id='Hlubb'></q></dir></style></legend>

      1. <tfoot id='Hlubb'></tfoot>
      2. 添加拖放后 CellDoubleClick 事件不起作用

        时间:2023-08-25

            <tbody id='mBGSy'></tbody>

          <small id='mBGSy'></small><noframes id='mBGSy'>

        1. <tfoot id='mBGSy'></tfoot>
              • <bdo id='mBGSy'></bdo><ul id='mBGSy'></ul>

                • <legend id='mBGSy'><style id='mBGSy'><dir id='mBGSy'><q id='mBGSy'></q></dir></style></legend>
                  <i id='mBGSy'><tr id='mBGSy'><dt id='mBGSy'><q id='mBGSy'><span id='mBGSy'><b id='mBGSy'><form id='mBGSy'><ins id='mBGSy'></ins><ul id='mBGSy'></ul><sub id='mBGSy'></sub></form><legend id='mBGSy'></legend><bdo id='mBGSy'><pre id='mBGSy'><center id='mBGSy'></center></pre></bdo></b><th id='mBGSy'></th></span></q></dt></tr></i><div id='mBGSy'><tfoot id='mBGSy'></tfoot><dl id='mBGSy'><fieldset id='mBGSy'></fieldset></dl></div>
                  本文介绍了添加拖放后 CellDoubleClick 事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在我添加了拖动 &拖放到 DataGridView,CellDoubleClick 事件停止工作.在 CellMouseDown 事件中,我有以下代码:

                  After I added drag & drop to a DataGridView, the CellDoubleClick event stopped working. In the CellMouseDown event I have the following code:

                  private void dataGridView2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
                  {
                      var obj = dataGridView2.CurrentRow.DataBoundItem;
                      DoDragDrop(obj, DragDropEffects.Link);
                  }
                  

                  如何更正此问题以启用 CellDoubleClick 事件?

                  How do I correct this to enable CellDoubleClick event?

                  推荐答案

                  是的,那行不通.调用 DoDragDrop() 将鼠标控制移交给 Windows D+D 逻辑,这将干扰正常的鼠标处理.您需要延迟启动 D+D,直到您看到用户实际拖动.这应该可以解决问题:

                  Yes, that cannot work. Calling DoDragDrop() turns mouse control over to the Windows D+D logic, that's going to interfere with normal mouse handling. You need to delay starting the D+D until you see the user actually dragging. This ought to solve the problem:

                      Point dragStart;
                  
                      private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) {
                          if (e.Button == MouseButtons.Left) dragStart = e.Location;
                      }
                  
                      private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e) {
                          if (e.Button == MouseButtons.Left) {
                              var min = SystemInformation.DoubleClickSize;
                              if (Math.Abs(e.X - dragStart.X) >= min.Width ||
                                  Math.Abs(e.Y - dragStart.Y) >= min.Height) {
                                  // Call DoDragDrop
                                  //...
                              }
                          }
                      }
                  

                  这篇关于添加拖放后 CellDoubleClick 事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:[C#][Selenium] 如何拖放元素 下一篇:拖放列表视图 C#

                  相关文章

                  最新文章

                  <tfoot id='Wc0xR'></tfoot>

                    1. <i id='Wc0xR'><tr id='Wc0xR'><dt id='Wc0xR'><q id='Wc0xR'><span id='Wc0xR'><b id='Wc0xR'><form id='Wc0xR'><ins id='Wc0xR'></ins><ul id='Wc0xR'></ul><sub id='Wc0xR'></sub></form><legend id='Wc0xR'></legend><bdo id='Wc0xR'><pre id='Wc0xR'><center id='Wc0xR'></center></pre></bdo></b><th id='Wc0xR'></th></span></q></dt></tr></i><div id='Wc0xR'><tfoot id='Wc0xR'></tfoot><dl id='Wc0xR'><fieldset id='Wc0xR'></fieldset></dl></div>
                    2. <legend id='Wc0xR'><style id='Wc0xR'><dir id='Wc0xR'><q id='Wc0xR'></q></dir></style></legend>
                    3. <small id='Wc0xR'></small><noframes id='Wc0xR'>

                      • <bdo id='Wc0xR'></bdo><ul id='Wc0xR'></ul>