在 C# Winforms 中检测 PropertyGrid 中打开的下拉框
情况: 我有一个窗口,里面渲染了 OpenGL 场景。在 OpenGL 场景旁边,我有一个场景中所选 3D 对象的 PropertyGrid。
场景中的对象可以通过其他方式进行更改,而不仅仅是编辑属性(例如,使用运行脚本来操作某些对象,该脚本移动/缩放/颜色/...场景中的对象)。为了在 PropertyGrid 中显示对象值的实时提要,网格会在每一帧刷新,如下所示:
void OnFrame()
{
myPropertyGrid.Refresh();
}
问题: 由于刷新每一帧,我无法在 PropertyGrid 中打开任何下拉框(打开的下拉框在 PropertyGrid 刷新时立即关闭)。
问题:是否有某种方法可以检测下拉列表是否打开(例如要检查的属性或要订阅的事件),并在这种情况下防止刷新?
void OnFrame()
{
if ( !PropertyGridInEditMode() ) // <-- What should this function check?
myPropertyGrid.Refresh();
}
注意:显然,简单检查 myPropertyGrid.ContainsFocus
只需在 PropertyGridItem 值字段中输入就可以正常工作,但无法检测下拉列表是否打开(我认为这是因为下拉表单是通过 IWindowsFormEditorService
调用的,因此下拉列表是一个单独的表单,不是PropertyGrid 的子级)。
Situation:
I have a window with an OpenGL scene rendered inside. Next to the OpenGL scene, I have a PropertyGrid of the selected 3D object in the scene.
Objects in the scene can be changed in other ways than just editing the properties (e.g. some objects are manipulated with a running script which moves / scales / colors / ... objects in the scene). To show a live feed of the object's values in the PropertyGrid, the grid gets refreshed each frame, like so:
void OnFrame()
{
myPropertyGrid.Refresh();
}
Problem: Because of this refresh each frame, I can't open any dropdown box in the PropertyGrid (an open dropdown box gets closed immediately on a PropertyGrid refresh).
Question: Is there some way to detect that a dropdown is open (e.g. a property to check or event to subscribe to), and prevent refreshing while this is the case?
void OnFrame()
{
if ( !PropertyGridInEditMode() ) // <-- What should this function check?
myPropertyGrid.Refresh();
}
Note: Apparently, a simple check on myPropertyGrid.ContainsFocus
works fine when simply typing in a PropertyGridItem value field, but it fails to detect if a dropdown is open (I assume that's because the dropdown form is called with IWindowsFormEditorService
and thus the dropdown is a separate form that's not a child of the PropertyGrid).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论