{"id":1957,"date":"2022-08-30T15:20:51","date_gmt":"2022-08-30T15:20:51","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/05\/trying-to-bind-devxpress-button-enabled-to-an-extended-binding-list-property-and-it-is-not-working-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:51","modified_gmt":"2022-08-30T15:20:51","slug":"trying-to-bind-devxpress-button-enabled-to-an-extended-binding-list-property-and-it-is-not-working-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/trying-to-bind-devxpress-button-enabled-to-an-extended-binding-list-property-and-it-is-not-working-collection-of-common-programming-errors\/","title":{"rendered":"Trying to bind devxpress button.Enabled to an extended binding list property and it is not working-Collection of common programming errors"},"content":{"rendered":"<p>I have an extended binding list for my purposes:<\/p>\n<pre><code>public class MyList : BindingList, INotifyPropertyChanged\n{\n    private List invalidObjectsList;\n\n    public MyList() : base()\n    {\n        invalidObjectsList = new List();\n    }\n\n    ...\n\n    public bool IsValid \n    {\n        get\n        {\n            return invalidObjectsList.Count == 0;\n        }\n    }\n\n    ...\n\n    \/\/ I have similar method for deletion\n    AddElementToInvalidList(T element)\n    {\n        invalidObjectsList.Add(element);\n        OnPropertyChanged(\"IsValid\");\n    }\n\n    ...\n\n    \/\/ Stuff for the INotifyPropertyChanged interface\n    public event PropertyChangedEventHandler PropertyChanged;\n\n    protected void OnPropertyChanged(string name)\n    {\n        PropertyChangedEventHandler handler = PropertyChanged;\n\n        if (handler != null)\n        {\n            handler(this, new PropertyChangedEventArgs(name));\n        }\n    }\n\n    ...\n}\n<\/code><\/pre>\n<p>I am designing the UI to be able to use that list to modify and save data to let&#8217;s say database. So in the UI I have a DevXpress button to &#8220;Save Data&#8221;. The actual list is assigned as <strong>dynamic<\/strong>, meaning:<\/p>\n<pre><code>dynamic list = DataProvider.GetObjectsList();\n<\/code><\/pre>\n<p>For that &#8220;Save data&#8221; button I am trying to bind it&#8217;s &#8220;Enabled&#8221; property to the &#8220;IsValid&#8221; property of my list as follows:<\/p>\n<pre><code>saveButton.DataBindings.Add(\"Enabled\", list, \"IsValid\");\n<\/code><\/pre>\n<p>At run time I am getting unhandled Exception:<\/p>\n<pre><code>Cannot bind to the property or column IsValid on the DataSource.\nParameter name: dataMember\n<\/code><\/pre>\n<p>I can&#8217;t figure out what&#8217;s wrong here. Please, help.<\/p>\n<p>Thanks in advance!<\/p>\n<p id=\"rop\"><small>Originally posted 2013-12-05 16:31:52. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have an extended binding list for my purposes: public class MyList : BindingList, INotifyPropertyChanged { private List invalidObjectsList; public MyList() : base() { invalidObjectsList = new List(); } &#8230; public bool IsValid { get { return invalidObjectsList.Count == 0; } } &#8230; \/\/ I have similar method for deletion AddElementToInvalidList(T element) { invalidObjectsList.Add(element); OnPropertyChanged(&#8220;IsValid&#8221;); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1957","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1957"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1957\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}