How can i DO this

  • Thread starter news.microsoft.com
  • Start date
N

news.microsoft.com

I have a struct but I have properties in that struct public and I want them
to be visible in the designer for a user control

so I have a property of SomeItem.Name, SomeItem.Value blah blah

how can I retain that tree in the designer property window?
 
B

B Mermuys

Hi,

news.microsoft.com said:
I have a struct but I have properties in that struct public and I want them
to be visible in the designer for a user control

so I have a property of SomeItem.Name, SomeItem.Value blah blah

how can I retain that tree in the designer property window?

I don't think this works for structs. If you have a property which exposes
a struct, then this struct is given by value (copy). Assume that there is a
property SomeItem, which returns a struct, then you cannot simply modify the
members of this struct:
e.g. MyUsercontrol.SomeItem.Name = "Test"; will not work... You're trying to
change a tempory copy.


Now, with classes/objects this works fine.

Before the property that exposes an object, put:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

And before the class which you return an object of, put:
[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConvert
er))]

The IDE only expands/persists the public properties.

HTH
greetings

---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top