Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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
Posted
Comments
VJ Reddy 23-May-12 20:44pm    
Thank you for response and for accepting the solution :)

1 solution

For the properties of the object set at design to be persisted in the form the DesignerSerializationVisibilityAttribute with the argument DesignerSerializationVisibility.Content is to be used like
VB
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public ReadOnly Property Dimensions() As DimensionData
   Get
       Return New DimensionData(Me)
   End Get
End Property

as explained here
http://msdn.microsoft.com/en-us/library/system.componentmodel.designerserializationvisibilityattribute.aspx#Y1900[^]
 
Share this answer
 
Comments
Sandeep Mewara 23-May-12 13:43pm    
My 5!

Good answer.


Comment from OP:
Thanks a lot.
this worked perfect. I, actually read an article wich says that changes were temporary but couldn't found a solution from there in spite looking for one through there.

Thanks again, a lot
VJ Reddy 23-May-12 20:43pm    
Thank you, Sandeep :)
Espen Harlinn 23-May-12 18:18pm    
Agree :-D
VJ Reddy 23-May-12 20:43pm    
Thank you, Espen :)
Maciej Los 24-May-12 12:00pm    
Good answer, +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900