Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 3.03 KB

File metadata and controls

57 lines (39 loc) · 3.03 KB

WinForms Data Grid - Bind to a queryable source (LinqInstantFeedbackSource)

This example shows how to bind the WinForms Data Grid to LinqInstantFeedbackSource.

Set the LinqInstantFeedbackSource.KeyExpression property to a key property name.

linqInstantFeedbackSource.KeyExpression = "SupplierID";

Handle the LinqInstantFeedbackSource.GetQueryable event. Set the e.QueryableSource property.

void OnGetQueryable(object sender, GetQueryableEventArgs e) {
    NorthwindClassesDataContext dt = new NorthwindClassesDataContext();
    e.QueryableSource = dt.Suppliers;
    e.Tag = dt;  
}

Handle the LinqInstantFeedbackSource.DismissQueryable event to dispose of a DataContext object when it is no longer required.

void OnDismissQueryable(object sender, GetQueryableEventArgs e) {
    (e.Tag as NorthwindClassesDataContext).Dispose();
}

Bind LinqInstantFeedbackSource to the Grid control.

gridControl1.DataSource = linqInstantFeedbackSource;

Files to Review

See Also

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)