.Net UserControl的设计问题 [英] Design problems with .Net UserControl

查看:65
本文介绍了.Net UserControl的设计问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个其中包含 ListView 的UserControl。通过属性可以公开访问ListView。当我将UserControl放在窗体中并尝试通过属性设计 ListView 时, ListView 会一直保持这种状态,直到我再次编译,它恢复为默认状态。

I have created a UserControl that has a ListView in it. The ListView is publicly accessible though a property. When I put the UserControl in a form and try to design the ListView though the property, the ListView stays that way until I compile again and it reverts back to the default state.

如何使我的设计更改适用于 ListView

How do I get my design changes to stick for the ListView?

推荐答案

您需要使用DesignerSerializationVisibility属性装饰ListView属性,例如:

You need to decorate the ListView property with the DesignerSerializationVisibility attribute, like so:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ListView MyListView { get { return this.listView1; } }

这告诉设计者的代码生成器为其输出代码。

This tells the designer's code generator to output code for it.

这篇关于.Net UserControl的设计问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆