0

First of all what I did (easier to explain what I want to get):

I've created a simple user control with a designer property of type List<bool>.

[Browsable(true)]
[Description("Select some.")]
[Category("SelectionTest")]
public List<bool> BoolList = new List<bool>();

When dragging this control onto my form and inspecting the designer I get this:

enter image description here

This one will open an editor:

enter image description here

Goal:

I would like to add another property of type string so it gets shown as the display-text on the left side. I dont care if it's editable.

So in general I would need something like List<string, bool> which isn't possible, i know. Unfortunately Dictionary and Tuple arn't working. When opening the editor, it will be still a single value shown as Value: (string, bool).

Anyone got an idea how to get another property into the right window or change the descriptions of the bools?

Would really appreciate every help in here. I guess this would be very nice knowledge to have. Think about the possibilities...

Thanks!

C4d
  • 3,183
  • 4
  • 29
  • 50

1 Answers1

1

I understand that you want named booleans

public partial class UserControl1 : UserControl
{
    [Browsable(true)]
    [Description("Select some.")]
    [Category("Selection Test"), DisplayName("Bool List")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public List<BoolProperty> BoolList { get; set; } = new List<BoolProperty>();

    public UserControl1()
    {
        InitializeComponent();
    }
}

[Serializable]
public class BoolProperty
{
    public string Name { get; set; }

    public bool Value { get; set; }

    public override string ToString()
    {
        return Name ?? "Empty Boolean Property";
    }
}

looks like:

looks like

Neuron
  • 5,141
  • 5
  • 38
  • 59
levent
  • 3,464
  • 1
  • 12
  • 22
  • Just found that solution on my own. For reasons of readability I'll edit yours just a bit so it can be set as the answer. Thank you very much btw! – C4d Jan 17 '17 at 14:43
  • Additional: Setting the categories of the properties from `BoolProperty` will have an effect inside the editor. – C4d Jan 17 '17 at 15:27