有没有办法在属性网格之外使用 CollectionEditor?
我正在用一些可以让我更好地自定义 UI 的东西替换我的属性网格。我在表单上放置了一个按钮,希望单击该按钮时会弹出一个 CollectionEditor 并允许我修改我的代码。当我使用 PropertyGrid 时,我所需要做的就是向指向我的 CollectionEditor 的属性添加一些属性,它就起作用了。但是如何手动调用 CollectionEditor 呢?谢谢!
I'm replacing my property grid with something that will allow me to customize my UI a bit better. I placed a button on my form that I hope when clicked would pop up a CollectionEditor and allow me to modify my code. When I was using the PropertyGrid, all I needed to do was add some attributes to the property pointing to my CollectionEditor and it worked. But how do I invoke the CollectionEditor manually? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这里找到答案:http://www.devnewsgroups.net/windowsforms/t11948-collectioneditor。 aspx
以防万一上面链接的网站有一天消失,这就是它的要点。然而,该代码是从上面的链接逐字逐句获取的;评论是我的。
假设您有一个带有列表框和按钮的表单。如果您想使用 CollectionEditor 编辑 ListBox 中的项目,您将在 EventHandler 中执行以下操作:
现在您需要做的下一件事是创建 RuntimeServiceProvider()。这是上面链接中的发帖人为实现此目的而编写的代码:
Found the answer here: http://www.devnewsgroups.net/windowsforms/t11948-collectioneditor.aspx
Just in case the site linked above goes away some day, here's the gist of it. The code is verbatim from the link above, however; the comments are mine.
Assume you have a form with a ListBox and a button. If you wanted to edit the items in the ListBox using the CollectionEditor, you would do the following in your EventHandler:
Now the next thing you need to do is to create the RuntimeServiceProvider(). This is the code the poster in the link above wrote to implement this:
由于我无法发表评论,因此我将在此发布:
您可以通过在 WindowsFormsEditorService.ShowDialog 中的 CollectionEditor 的 okButton 上添加 Click 事件来获取 DialogResult
...
Since I can't comment i'll post this here:
You can get the DialogResult by adding a Click event on the okButton of the CollectionEditor in WindowsFormsEditorService.ShowDialog
...