I have a control which I can add some other controls in it.
I need to add those controls in object initialization but it will give me an error that the Controls property is an indexer
and it is read-only
. so I should add in it in another line using the Add
method. Is there any way to do such thing in object initialization?
pgvSections.Pages.Add(new PageView() { Name = sectionName, /* Controls = DOES NOT ALLOWED */ });
pgvSections.Pages.Last().Controls.Add(someControl);