.net - WPF 2-Way Databound DataGrid -
Does anyone point me to a very simple example of a WPF Datagrid (C # 4.0) bound to a SQL table I would really like the simplest example I want to be able to add, edit and delete rows. Thank you.
An old thread seems to be, but hopefully it will still be useful. If you can get your data in the Observe Collection, then the most difficult things will be done for you. From there you can do something like this:
Observing Collections & lt; Items & gt; OcItems = new reviewable collection & lt; Items & gt; (); OcItems.Add (new item ()); DgGrid.ItemsSource = ocItems;
Or, if you want to do it in XML, you can do something like this:
> ; DataGrid name = "dgGrid" item source = "{binding ociittum, mode = two}" auto generated column = "true" />
And then make sure that you have an object named OCItitt which is in your code.
You can add updates for yourself and you can delete yourself so that you do not have to ask Don Datagrid to update, using the Twoway binding, you can add any Even editing which has been done for you as well, you can customize the look of DataGrid with DataGridColumns item, but I'll let you see yourself.
Comments
Post a Comment