• <tfoot id='1hur3'></tfoot>

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

      <small id='1hur3'></small><noframes id='1hur3'>

      • <bdo id='1hur3'></bdo><ul id='1hur3'></ul>

        拖放列表视图 C#

        时间:2023-08-25

            <legend id='5qmh2'><style id='5qmh2'><dir id='5qmh2'><q id='5qmh2'></q></dir></style></legend><tfoot id='5qmh2'></tfoot>
              <bdo id='5qmh2'></bdo><ul id='5qmh2'></ul>

                <tbody id='5qmh2'></tbody>

                  <small id='5qmh2'></small><noframes id='5qmh2'>

                  <i id='5qmh2'><tr id='5qmh2'><dt id='5qmh2'><q id='5qmh2'><span id='5qmh2'><b id='5qmh2'><form id='5qmh2'><ins id='5qmh2'></ins><ul id='5qmh2'></ul><sub id='5qmh2'></sub></form><legend id='5qmh2'></legend><bdo id='5qmh2'><pre id='5qmh2'><center id='5qmh2'></center></pre></bdo></b><th id='5qmh2'></th></span></q></dt></tr></i><div id='5qmh2'><tfoot id='5qmh2'></tfoot><dl id='5qmh2'><fieldset id='5qmh2'></fieldset></dl></div>
                • 本文介绍了拖放列表视图 C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  您好,当我双击列表视图时如何启用拖动事件处理程序?

                  Hi how to I enable drag event handler when I double click on the listview?

                  这是我双击列表视图后得到的

                  This is what I get after double-clicking on the listview

                  private void listView1(object sender, EventArgs e)
                  

                  但是,我希望它是

                  private void listView(object sender,DragEventArgs e)
                  

                  我该怎么做..?

                  我尝试了很多方法,例如:

                  I have tried many way such as:

                    private void Form_Load(object sender, EventArgs e)
                    {
                        // Enable drag and drop for this form
                        // (this can also be applied to any controls)
                        this.AllowDrop = true;
                  
                        // Add event handlers for the drag & drop functionality
                        this.DragEnter += new DragEventHandler(Form_DragEnter);
                        this.DragDrop += new DragEventHandler(Form_DragDrop);
                   }
                  

                  推荐答案

                  你需要实现DragEnter事件并设置DragEventArgs的Effect属性.DragEnter 事件允许将内容拖放到控件中.之后,DragDrop 事件将在释放鼠标按钮时触发.

                  You need to implement the DragEnter event and set the Effect property of the DragEventArgs. The DragEnter event is what allows things to be dropped into a control. After that the DragDrop event will fire when the mouse button is released.

                  这是一个允许将对象放入 ListView 的版本:

                  Here is a version that will allow objects to be dropped into the a ListView:

                      private void Form1_Load(object sender, EventArgs e)
                      {
                          listView1.AllowDrop = true;
                          listView1.DragDrop += new DragEventHandler(listView1_DragDrop);
                          listView1.DragEnter += new DragEventHandler(listView1_DragEnter);
                      }
                  
                      void listView1_DragEnter(object sender, DragEventArgs e)
                      {
                          e.Effect = DragDropEffects.Copy;
                      }
                  
                      void listView1_DragDrop(object sender, DragEventArgs e)
                      {
                          listView1.Items.Add(e.Data.ToString());
                      }
                  

                  毫无疑问,您的示例代码来自:http://msdn.microsoft.com/en-us/library/system.windows.forms.control.allowdrop(v=vs.71).aspx

                  No doubt your sample code was taken from : http://msdn.microsoft.com/en-us/library/system.windows.forms.control.allowdrop(v=vs.71).aspx

                  这篇关于拖放列表视图 C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:添加拖放后 CellDoubleClick 事件不起作用 下一篇:c#中如何区分拖放事件中的文件或文件夹?

                  相关文章

                  最新文章

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

                  <legend id='tHy7L'><style id='tHy7L'><dir id='tHy7L'><q id='tHy7L'></q></dir></style></legend>
                        <bdo id='tHy7L'></bdo><ul id='tHy7L'></ul>

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

                      <tfoot id='tHy7L'></tfoot>