Question I have a Question about make a User Controls Property and Property Browsers setting.

z_idea

New member
Joined
Dec 27, 2012
Messages
4
Programming Experience
3-5
Hello..

Sorry for can't be experience English..

anyway I make a UserControl , named by TLabelCombo.

and TLabelCombo have a Property.. like under code..
--------------------------------------------------
Class TLabelCombo : UserControl
{
public Control NextControl{get;set;}
}
--------------------------------------------------

and I added TLabelCombo to a Form, Visual Studio(2010, .net4)'s Designer Mode..

and I Watch NextControl, TLabelCombo's Property with VisualStudio Property Browser

I Can choice NextControl's Value, among Controls in Form.

but I have to Make the NextControl on List.. like under code..

--------------------------------------------------
Class TLabelCombo : UserControl
{
public List<Control> NextControls{get;set;}
}
--------------------------------------------------

TLabelCombo be built and once more I watch the Property Browser .
the NextControls Property in Property Browser changes from a ComboBox to a Container Editor.
I Click the Container Editor.. that's provide for add multi control to NextControls.
but at this time ,a problem comes up.. Nowhere I can't find Form's child Control..
just able to add new Controls and add new Controls..

I want Add Controls in TLabelCombo's Parent Form to NextControls with Property Browser...
thanks for read it.
 
Last edited:

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,150
Location
Sydney, Australia
Programming Experience
10+
Firstly, you should not be declaring your property like that. When you have a property that is a collection type it should be defined like this:
public class LabelCombo : UserControl
{
    private List<Control> _nextControls = new List<Control>();

    public List<Control> NextControls
    {
        get
        {
            return _nextControls;
        }
    }
}
Now you can add and remove items in the existing list but you cannot replace the list with another and it cannot be set to null. That's basically how all collection properties work in .NET.

As for the question, you will have to build your own UITypeEditor, which is no small thing.

UITypeEditor Class (System.Drawing.Design)

You may well be able to start with the existing collection editor and add your own custom logic.

CollectionEditor Class (System.ComponentModel.Design)
 

z_idea

New member
Joined
Dec 27, 2012
Messages
4
Programming Experience
3-5
thanks for answer.. I'll try it .
have a nice day :)
 

z_idea

New member
Joined
Dec 27, 2012
Messages
4
Programming Experience
3-5
Dear jmcilhinney

Thanks for your advice.. !! :)

I tried it, and success that I have my custom logic collection editor.

but It's not Append in Designer.cs ..

So When Close the DesignMode Window, My saving Data Disapper :(

How can I solve It?
 
Top Bottom