Skip to content

Bind the WinForms Grid control to a queryable source (LinqInstantFeedbackSource).

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/winforms-grid-bind-to-linqinstantfeedbacksource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)