PictureBox 控件的拖放支持

发布于 2024-10-09 02:31:28 字数 281 浏览 0 评论 0原文

经过一番搜索后,我弄清楚了如何为图片框实现拖放。但有一件事 - (当然是继承的)allowdrop 属性无法从 picturebox 类的代码或属性窗口访问。因此,为了使其工作,我在表单加载中添加了以下行:

((Control)pictureBox1).AllowDrop = true;

为什么我必须这样做?在 msdn 中,它说:“此 API 支持 .NET Framework 基础结构,并不打算直接从您的代码中使用。”

任何解释都表示赞赏,并对我的语法感到抱歉;)

After some searching i figured out how dragdrop is implemented for a picturebox. But there is one thing - the (inherited of course) allowdrop property isn't accessible from code or property window of picturebox class. So to make it work i added following line to my form-load:

((Control)pictureBox1).AllowDrop = true;

Why do i have to do that? In msdn it says: "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code."

Any explanation appreciated and sorry for my grammar ;)

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

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

发布评论

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

评论(1

悸初 2024-10-16 02:31:28

PictureBox 类重写该属性并添加

[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 

这会阻止它在 IntelliSense 中显示。
但是,您仍然可以设置属性而不进行强制转换。

当属性不适用于控件时,Microsoft 会执行此操作。 (例如,PictureBox.Text
我不知道为什么AllowDrop不适用于PictureBox;消息来源没有提及任何内容。

The PictureBox class overrides the property and adds

[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 

This prevents it from being shown in IntelliSense.
However, you can still set the property without casting.

Microsoft does this when a property doesn't apply to a control. (eg, PictureBox.Text)
I don't know why AllowDrop wouldn't apply to a PictureBox; the source doesn't mention anything.

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