When clicking on datagrid row it throws me exception - WPF C# -


whenever try double click datagrid row edit it, throws me few exceptions doesn't me. hovever if set whole datagrid isreadonly true, want have problem, need second , third columns editable.

xaml

 <datagrid x:name="clientlist" horizontalalignment="left" height="225" margin="11,126,0,0" verticalalignment="top" width="349" issynchronizedwithcurrentitem="false" autogeneratecolumns="false" horizontalgridlinesbrush="#ffb9b9b9" verticalgridlinesbrush="#ff8b8b8b" gridlinesvisibility="horizontal" cellstyle="{staticresource body_content_datagrid_centering}">         <datagrid.resources>             <lineargradientbrush x:key="{x:static systemcolors.highlightbrushkey}" startpoint="0,0" endpoint="0,1" >                 <gradientstop color="#66240000" offset="0"/>                 <gradientstop color="#cc240000" offset="0.65"/>             </lineargradientbrush>         </datagrid.resources>         <datagrid.columns>             <datagridtextcolumn width="30" header="id" isreadonly="true" binding="{binding id}"/>             <datagridtextcolumn width="100" header="company" isreadonly="false" binding="{binding company}"/>             <datagridtextcolumn width="130" header="name, surname" isreadonly="false" binding="{binding name}"/>             <datagridtemplatecolumn header="actions" celltemplate="{staticresource mytemplate}"/>         </datagrid.columns>      </datagrid> 

c#

clientlist.items.add(new dataclients { id = 1, company = "my company", name = "jane roe"}); 

exceptions

exception:thrown: "'edititem' not allowed view."(system.invalidoperationexception)  exception:thrown: "the string not recognized valid datetime. there unknown word starting @ index 0." (system.formatexception) 

you should use observablecollection<dataclients>() source datagrid , not add items directly datagrid. this, create property observablecollection<dataclients> data , use itemssource in datagridlike itemssource="{binding mybikesorders}". can add items observablecollection, update datagrid , should able edit entries directly in it.

here's similar question yours.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -