简体   繁体   English

如何在WinForms中创建手动排列的列表视图?

[英]How do make a manually arrangeable listview in WinForms?

In my application's main window I'd like to have an interface very similar to that of Windows Desktop. 在我的应用程序的主窗口中,我想要一个非常类似于Windows桌面的界面。 There would be a bunch of icons with texts and you can drag them around and position them as you like. 会有一堆带有文字的图标,您可以随意拖动它们并将它们放置在自己喜欢的位置。 The standard ListView would almost do, except that it doesn't support this custom re-arranging. 标准ListView几乎可以做到,除了它不支持此自定义重新排列。 Any ideas on how to achieve this effect short of writing a completely new usercontrol from scratch? 除了从头开始编写全新的用户控件外,关于如何实现此效果的任何想法?

For this to be done you have to add max no of items into the list view. 为此,您必须在列表视图中添加最大项目数。 As I know list view will allow us to drag items only into already occupied area. 据我所知,列表视图将使我们只能将项目拖到已经占用的区域中。 You can fill the extra space using listview.Items.Add("") 您可以使用listview.Items.Add("")填充多余的空间

Once u have to add some new item u can replace the first blank item with the new item. 一旦您必须添加一些新项目,就可以用新项目替换第一个空白项目。 I tried this thing and it's working. 我尝试了这个东西,它正在工作。 One thing u have to handle is sorting. 您必须处理的一件事是排序。 While sorting u have to omit the blank items. 在排序时,您必须省略空白项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM