在 WebBrowser 组件上放置项目时出现问题

发布于 2024-12-02 05:07:16 字数 703 浏览 0 评论 0原文

我想将一些控件从自定义工具箱拖放到 WebBrowser 组件上。因为该组件不支持拖放,所以我使用包装器来捕获 DragEnter、DragOver 等。当应用程序仍配置为在 .NET Framework 2.0 中工作时,此方法运行良好。

由于某些原因,我不得不升级到 .Net Framework 4.0。我的包装器的所有拖放功能都已损坏。不会触发任何事件。像“导航”这样的事件仍然工作正常......

我已经准备好寻找可能的答案并尝试了一些方法,但我无法修复它。有人有任何线索吗?目前,我正在考虑实现以下位置给出的包装器: Codeproject

感谢您的宝贵时间!

编辑1(和2): 我继续寻找答案并发现了以下内容:

  1. DragEnter 事件应该在某处触发,因为正确的图标出现在浏览器上。该图标似乎仅在正确设置 DragDropEffect 时才会出现。但我找不到 DragEnter 事件(或其他事件)的处理程序。

  2. 我试图将想要的项目放到另一个屏幕部分上。屏幕的这一部分不包含很多组件,因此在那里实现放置操作非常容易。而且效果很好。我能够从 eventArgs 中获取该对象。但它仍然无法在网络浏览器组件上运行。

也许这些线索可以帮助您解决这个问题。

I would like to drop some controls from a self-defined toolbox onto a WebBrowser component. Because this component doesn't support drag-drop I use a wrapper to catch DragEnter, DragOver, ... This method worked fine while the application was still configured to work in .NET framework 2.0.

For some reasons I had to upgrade to .Net framework 4.0. All drag and drop functionality with my wrapper is broken. No events are triggered whatsoever. Events like "navigated" are still working fine...

I allready searched for possible answer and tried a few things but I couldn't fix it. Does anybody has any clue? Currently I'm thinking about implementing the wrapper given at: Codeproject

Thanks for your time!

EDIT 1 (& 2):
I continued my search for answers and discovered the following stuff:

  1. The DragEnter-event should be fired somewhere because the right icon appears on the browser. This icon only seems to appear when a DragDropEffect is set correctly. But I can't find the handler for the DragEnter-event (or other).

  2. I tried to drop the wanted item onto an other screen part. This part of the screen doesn't contain a lot of components so it was pretty easy to implement the drop-action there. And it worked fine. I was able to get the object out of the eventArgs. But it's still not working on the webbrowser-component.

Maybe these clues can help you to sort out this problem.

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

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

发布评论

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

评论(1

裂开嘴轻声笑有多痛 2024-12-09 05:07:16

我实际开始工作的第一种方法是在 javascript 代码中添加一些事件和处理程序。我设置的事件是:

  • ondragenter
  • ondragover
  • ondragleave
  • ondrop (不是 ondragdrop !!!)

通过在 javascript 中处理这些事件并将事件发送到 C# 代码,我可以根据需要处理这些事件。

为了到达我正在拖动的控件,我实现了一个小“剪贴板”。通过这个静态类,我可以保留正在拖动的控件并从“onDragEnter”代码访问它。

The first way I actually got working is by adding some events and there handlers within javascript code. The events I've set are:

  • ondragenter
  • ondragover
  • ondragleave
  • ondrop (NOT ondragdrop !!!)

By handling these events within javascript and sending the event to C#-code I could handle these events as wanted.

To get to the control I'm dragging I implemented a little "clipboard". With this static class I'm able to hold the control I'm dragging and access it from the "onDragEnter"-code.

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