DragDrop-Support of PictureBox-Control

两盒软妹~` 提交于 2019-12-10 23:26:10

问题


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 ;)


回答1:


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.



来源:https://stackoverflow.com/questions/4519728/dragdrop-support-of-picturebox-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!