PictureBox 控件的拖放支持
经过一番搜索后,我弄清楚了如何为图片框实现拖放。但有一件事 - (当然是继承的)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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PictureBox
类重写该属性并添加这会阻止它在 IntelliSense 中显示。
但是,您仍然可以设置属性而不进行强制转换。
当属性不适用于控件时,Microsoft 会执行此操作。 (例如,
PictureBox.Text
)我不知道为什么AllowDrop不适用于PictureBox;消息来源没有提及任何内容。
The
PictureBox
class overrides the property and addsThis 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.