Quantcast
Viewing all articles
Browse latest Browse all 3

WPF - eidt row in datagrid

What kind of data? If you retrive the data to be edited from a database, you can simply set ItemsSource property of the DataGrid to the DefaultView of the DataTable and then double click on any cell in the DataGrid to begin to edit it:

<DataGrid x:Name="dgrid" />

dgrid.ItemsSource = dataSet.Tables[0].DefaultView;

If you don't get the data to be edited from a database, you could create your own class and add a property for each column to be edited in the DataGrid and set its ItemsSource property to a collection of objects of this type:

public class MyType
{
 public string Id { get; set; }
 public string string { get; set; }
}

dgrid.ItemsSource = new List<MyType>() { new MyType { Id = "1", Name = "First" } };

Please refer to the following links for more information:
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(v=vs.110).aspx
http://www.codeproject.com/Articles/30905/WPF-DataGrid-Practical-Examples


Viewing all articles
Browse latest Browse all 3

Trending Articles