Design Issues .Net UserControl

I created a UserControl in which there is ListView. ListView is a public property though. When I put a UserControl on the form and try to create a ListViewproperty, it ListViewstays that way until I compile it again and it returns to its default state.

How do I change my design changes for ListView?

+3
source share
3 answers

You need to decorate the ListView property with the DesignerSerializationVisibility attribute, for example:

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

This tells the developer code generator to output the code for it.

+6
source

Fredrik , , , , . , ASPX, .

.

, ( ) ASP.NET, . , , WinForms ( ).

+1

, , - , ?

public ListView MyListView { get { return this.listView1; } }

So, you get (at design time) the MyListView property in UserControl?

I think that if you need the right development-time support, you better change the "Modifier" property in the ListView itself (back to the original UserControl) to Public - this way you can change the ListView directly on instances of UserControl. In any case, I have succeeded.

0
source

Source: https://habr.com/ru/post/1696443/


All Articles