Extended WPF Toolkit™ Community Edition DataGrid


The free Community Edition of the Exceed DataGrid is simple, easy-to-use, and robust.

This basic example shows common things such as a column with a date and one formatted for currency. Note that the date column will display a date icon when editing. Clicking on this date icon will display a month date-dropdown.

Basic Example
Xceed.Wpf.DataGrid.DataGridControl XceedGrid = new Xceed.Wpf.DataGrid.DataGridControl();
#region Build Sample DataSet
DataSet ds2 = new DataSet("testDs");
DataTable dsTestTable2 = new DataTable("Test");

dsTestTable2.Columns.Add(new DataColumn("Attraction", typeof(string)));
dsTestTable2.Columns.Add(new DataColumn("Location", typeof(string)));
dsTestTable2.Columns.Add(new DataColumn("Column 3", typeof(DateTime)));
dsTestTable2.Columns.Add(new DataColumn("Column4", typeof(Decimal)));
dsTestTable2.Columns.Add(new DataColumn("Validation Errors", typeof(string)));
dsTestTable2.Columns.Add(new DataColumn(" ", typeof(string)));
DataRow row12 = ds2.Tables[0].NewRow();
DataRow row22 = ds2.Tables[0].NewRow();

row12["Attraction"] = "";
row12["Location"] = "Chicago, IL";

row22["Attraction"] = "Lisle Arboretum";
row22["Location"] = 5000.00.ToString("C2");
row12["Column 3"] = DateTime.Today;
row12["Column4"] = 500.00D;
row22["Column 3"] = DateTime.Today;
row22["Column4"] = 7000.00D;


XceedGrid.Initialize(800D, 300D, ds2);
XceedGrid.Columns[4].Width = 134D;
XceedGrid.Columns[5].Width = 134D;
// XceedGrid.Columns[5].Visible = false;  //example of hiding a column

Add a New Row

Delete Selected Row
XceedGrid.DeleteSelectedRow(() => { MessageBox.Show("Perform action on delete: <such as removing item from background collection?>"); });

Validate Rows
XceedGrid.ValidateRows(4, new Predicate<DataRowView>(
drv => { return (drv as DataRowView).Row[0].ToString() == ""; }),
"ERROR - Required Field!");

public static List<DataRowView> ValidateRows(this Xceed.Wpf.DataGrid.DataGridControl dgc, int errorColumn, Predicate<DataRowView> pred, string validationErrorMessage)
            if (dgc.CurrentItem != null)
                Xceed.Wpf.DataGrid.DataRow row = dgc.GetContainerFromItem(dgc.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;
                if (row != null)
                    DataGridCommands.EndEdit.Execute(null, row);

            List<DataRowView> drvList = new List<DataRowView>();

            foreach (object zx in ((DataGridCollectionView)dgc.ItemsSource).SourceItems) //XceedGrid.ItemsSource)
                if (pred(zx as DataRowView))
                    (zx as DataRowView).Row[errorColumn] = validationErrorMessage;
                    if ((zx as DataRowView).Row[errorColumn] != DBNull.Value)
                        (zx as DataRowView).Row[errorColumn] = String.Empty;

return drvList;

Last edited May 26, 2014 at 4:02 AM by stagathome0069, version 9


No comments yet.