you could implement a TypeConverter
for your Values
class
Edit List in PropertyGrid
-
11-04-2022 - |
Question
I have a PropertyGrid
(winform) that contains a list of positions.
private ValuesCollection _position1 = new ValuesCollection();
public ValuesCollection Position1
{
get { return _position1; }
set
{
_position1 = value;
}
}
ValuesCollection this class that I made with the following article: Customized display of collection data in a PropertyGrid
Each object in the list it belongs to class Values:
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Values
{
[Browsable(false)]
public string Name { get; set; }
public virtual double Value { get; set; }
public Values()
: this(null, 0)
{
}
public Values(string name, double value)
{
Name = name;
Value = value;
}
public override string ToString()
{
return Value.ToString();
}
}
My problem is that I can not edit in the first level when the list opens because each item is an object.
I have to open another level (open the object itself) and edit there.
I want to edit in the first level and not open any object alone. I have not found a way to do it, does anyone have an idea?
(P.S. I do not want to use the Collection Editor
.)
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow