c# - Update issue with data-bound Listbox and PropertyGrid -
this part of aoi class (nothing special it):
class aoi : inotifypropertychanged { private guid _id; private string _name; private string _comment; public guid id { { return _id; } } public string name { { return _name; } set { _name = value; onpropertychanged("name"); } } public string comment { { return _comment; } set { _comment = value; onpropertychanged("comment"); } } public override string tostring() { if (_name.length > 0) { return _name; } else { return _id.tostring(); } } }
i keep them in bindinglist<aoi>
bound listbox
. in selectedvaluechanged
event of listbox
assign selected object propertygrid
, user can modify aoi
.
this works fine except name field (which displayed in listbox
(see tostring()
above)).
when edit name field using propertygrid
, listbox
updated correctly. in propertygrid,
name
field (just value) cleared press enter. correct (modified) value appears when set cursor field in propertygrid
.
what easiest workaround handle correctly?
this problem of propertygrid.
this can reproduced designer within visual studio. select control , change minimum size larger value current one. if take grid, value in size property won't updated till select within grid.
if rows won't update correctly 1 of these 2 options help:
- reattach object propertygrid calling
propertygrid.selectedobject = myobject
- force grid redraw calling
propertygrid.invalidate()
Comments
Post a Comment