List in property grid c# -


i have list used property grid, want eliminate possibility of adding via button - add.

but want able edit data are.

my list:

    private list<pos> _position = new list<pos>();      public list<pos> position     {         { return _position; }         set         {             _position = value;             notifypropertychanged("position");         }     } 

pos.cs:

public class pos {     public string name { get; set; }     public double postion { get; set; }      public pos()         : this(null, double.nan)     {      }      public pos(string name, double postion)     {         this.name = name;         this.postion = postion;     } } 

i tried put [readonly(true)] above list, still gives option of adding.

does have idea how it?

i canceled option add / delete, this:

i created generic class:

public class poslist<t> : list<t>, icollection<t>, ilist {      public valueslist(ienumerable<t> items) : base(items) { }      bool icollection<t>.isreadonly { { return true; } }      bool ilist.isreadonly { { return true; } }  } 

that gives possibility add/remove ​​in code, not through collection editor.

use:

private poslist<pos> _position = new poslist<pos>(new list<pos>());  public poslist<pos> position {     { return _position; }     set     {         _position = value;         notifypropertychanged("position");     } } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -