如何启用拖放功能放下所有子控件

发布于 2024-08-10 14:28:05 字数 504 浏览 5 评论 0原文

我的情况如下,我有带有 DockPanel Suite 和很多控件的 win-forms 应用程序,覆盖整个屏幕,

我想启用从 Windows 资源管理器到应用程序的文件 D&D。我知道如何实现 D&D,但似乎如果我为主父窗体启用它,则只有应用程序标题栏和任务菜单图标反映 D&D 中的更改。

我希望整个表单接受来自资源管理器的文件。我是否必须为应用程序中显示的每个顶部控件启用文件的 D&D?

我确信有更好的方法来实现这一点,有帮助吗?

澄清

当用户将文件从 Windows 资源管理器拖动到我的表单时,我希望表单中的每个位置都能针对此类事件提供反馈。就像您可以将文件从资源管理器拖动到 Visual Studio 一样,无论将其拖动到哪里,应用程序都会接受该文件。

My situation is as follows, I have win-forms applications with DockPanel Suite and lots of controls, which cover the entire screen,

I want to enable D&D of files from the windows explorer to the application. I know how to implement the D&D, but it seems that if i enable it for the main parent form, only the applications title-bar and task-menu icon reflect the change in the D&D.

I want the entire form to accept the files from the explorer. Do i have to enable D&D of files for each top control displaying in my application?

I am sure there is a better way to implement this, help?

Clarify

When a user drags files from the windows explorer to my form, I want every place in the form to give a feedback for such an event. Much like you can drag a file from the explorer to the Visual Studio, and it doesn't matter to where you drag it, the application accepts the file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

羅雙樹 2024-08-17 14:28:05

我没有使用过 DockPanel 套件,但使用 Visual Studio 表单设计器创建启用表单拖放功能并在表单上添加适当的处理程序,几乎我添加的所有内容(未更改属性)都允许表单“查看”拖/放操作。包括,Panel、SplitContainer、TabControl、ListBox、Button、ListView。我尝试过的唯一不起作用的(也是我到达此页面时遇到的问题)是 RichText 控件,我想这是因为它允许拖放编辑。

我的猜测是这是 DockPanel 套件特定的行为。我对此一无所知,但我猜它必须使用拖放来实现其停靠功能。也许您可以在 DockPanel 面板级别而不是表单级别挂钩一些事件。

I've not used DockPanel suite, but with Visual Studio form designer creating form drop enabled and appropriate handers on the form, almost everything I add (no properties changed) allows the form to "see" the drag/drop. Including, Panel, SplitContainer, TabControl, ListBox, Button, ListView. The only thing I tried that didn't work (and the question I had when I arrived at this page) was the RichText control, I guess that's because it allows Drag-n-Drop editing.

My guess would be this is DockPanel suite specific behaviour. I don't know anything about that, but I'd guess it has to consume drag-n-drop to implement its dock functions. Maybe there are events you can hook at the DockPanel panel level rather than the form level.

-柠檬树下少年和吉他 2024-08-17 14:28:05

我在使用 DevExpress 的组件时遇到了类似的问题,但通过确保所有用户控件都设置了 AllowDrop = false 来解决这个问题。基本上,在解决方案上搜索 AllowDrop = true 并确保只有您的主窗体设置了它(您可以从所有受影响的设计器中删除所有此类行,因为 false 是默认值。

这允许我有一个地方来处理所有拖/放操作。

I had a similar problem using components from DevExpress, but managed to solve it by making sure all user controls had AllowDrop = false set. Basically, run a search for AllowDrop = true on the solution and make sure ONLY your main form has it set (you can remove all such lines from all affected designers since false is the default value.

This allows me to have one place that handles all drag/drop operations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文