用户控件的项目收集选项
正如您在下图中看到的,对于 ListView 控件,您可以使用“属性”窗格添加项目。
如何为我的用户控件启用此类功能?
当我搜索 Google 时,我没有得到任何结果,但我可能没有使用正确的术语。
有人知道吗?
谢谢
As you can see in the pic below, for a ListView Control you can add Items using the Properties pane.
How do I enable this kind of stuff for my UserControl?
I'm not getting anything when I search Google, but I'm probably not using the correct terms.
Does anybody know?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要创建一个类来定义集合 id 组成的对象类型。 listView 具有 ListViewItem 对象。 TabControl 具有 TabPage 对象。您的控件具有由您定义的对象。我们将其称为 MyItemType。
您还需要该集合的包装类。一个简单的实现如下所示。
最后,您需要将集合的成员变量添加到用户控件并正确装饰它:
现在您有一个简单的界面,允许您浏览和编辑集合。还有很多需要改进的地方,但要做更多的事情,您将必须了解定制设计器,这可能很难理解和实现。
You need to create a class that defines the object type that the collection ids composed of. A listView has ListViewItem objects. A TabControl has TabPage objects. Your control has objects which are defined by you. Let's call it MyItemType.
You also need a wraper class for the collection. A simple implementation is shown below.
Finally you need to add a member variable for the collection to your user control and decorate it properly:
and you now have a simple interface that allows you to browse and edit the collection. Leaves a lot to be desired still but to do more you will have to learn about custom designers which can be difficult to understand and implement.