列标题从列表视图中消失 [英] Column headers dissapearing from listview
问题描述
大家好.
我正在尝试创建与组合框非常相似的自定义Comtrol,但是只显示列表视图而不是列表框,您可以像在常规列表视图控件中那样在其中添加/显示列和项目.
我发现的一个问题是,在将自定义控件添加到表单以测试该控件并将列和项目添加到列表视图之后,我在运行表单时在设计时添加的列和项目就会消失. br/>
奇怪的是,除了列和项目之外,我创建的所有其他属性都会在设计时保留设置的值.
我现在开始创建自定义控件,但到目前为止我找不到解决问题的方法.
在此先感谢您提供的任何帮助,对不起我的英语,但这不是我的母语.
感谢
Hi everyone.
I''m trying to create a custom comtrol much similar to a combobox,but wich display a listview instead of a listbox, where you can add/show columns and items as you would in a regular listview control.
The one problem i''m finding is that after i add the custom control to a form to test the control and add columns and items to the listview, the columns and items i added at design-time dissapear when i run the form.
Curiously, at exception of columns and items, every other property i created keeps the values set at design-time.
I''m starting now creating custom controls and i couldn''t find a solution for my problem so far.
Thanks in advance for any help you can give, and sorry for my english but it isn''t my first language.
Thanks
推荐答案
要使设计时设置的对象的properties
以DesignerSerializationVisibilityAttribute
形式并带有参数DesignerSerializationVisibility.Content
的形式持久化,就像
For theproperties
of the object set at design to be persisted in the form theDesignerSerializationVisibilityAttribute
with the argumentDesignerSerializationVisibility.Content
is to be used like
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public ReadOnly Property Dimensions() As DimensionData
Get
Return New DimensionData(Me)
End Get
End Property
如此处所述
http://msdn.microsoft.com/en-us/library/system. componentmodel.designerserializationvisibilityattribute.aspx#Y1900 [ ^ ]
as explained here
http://msdn.microsoft.com/en-us/library/system.componentmodel.designerserializationvisibilityattribute.aspx#Y1900[^]
这篇关于列标题从列表视图中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!