- Notifications
You must be signed in to change notification settings - Fork1
Edit the focused grid row in DataLayoutControl in Server Mode.
License
DevExpress-Examples/winforms-grid-edit-row-server-mode
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Server Mode does not work if you bind the GridControl and DataLayoutControl to the same collection, and use the DataLayoutControl as the grid's Edit Form, because the CurrencyManager does not manageServer Mode Data Sources. All Server Mode data sources except forXPServerCollectionSource are read-only.
This example handles theFocusedRowChanged event to synchronize the DataLayoutControl's data source (XPBindingSource orBindingSource) with the focused row in the GridControl.
- Bind the
DataLayoutControlto a data source in the Visual Studio Designer.
- If your ORM is XPO, add theXPBindingSource component from the toolbox.
- Rebuild the project.
- Select theXPBindingSource.ObjectClassInfo property in the Properties window, open the drop-down list, and choose an appropriate XPO class.
- Assign
XPBindingSourceto theDataLayoutControl.DataSource property.
- If your ORM is EF or a different library, add theBindingSource component from the toolbox.
- Rebuild the project.
- Click theProject > Add New Data Source menu item.
- Choose the Object Data Source Type and click Next.
- Choose an appropriate class in the list and clickFinish.
- Assign
BindingSourceto theDataLayoutControl.DataSource property.
- Retrieve data fields.
- Select the
GridViewand subscribe to theFocusedRowChanged event. - Use the
e.Rowproperty to obtain a data object that corresponds to the focused row and add it to the data source.
privatevoidGridView_FocusedRowObjectChanged(objectsender,FocusedRowObjectChangedEventArgse){XPBindingSource.DataSource=Session.GetLoadedObjectByKey<ServerSideGridTest>(e.Row);}
PrivateSubGridView_FocusedRowObjectChanged(ByValsenderAsObject,ByValeAsFocusedRowObjectChangedEventArgs)XPBindingSource.DataSource=Session.GetLoadedObjectByKey(OfServerSideGridTest)(e.Row)EndSub
privatevoidGridView_FocusedRowObjectChanged(objectsender,FocusedRowObjectChangedEventArgse){objectobj=DbContext.ServerSideGridTests.Single(e.Row);BindingSource.Clear();BindingSource.Add(obj);}
PrivateSubGridView_FocusedRowObjectChanged(ByValsenderAsObject,ByValeAsFocusedRowObjectChangedEventArgs)DimobjAsObject=DbContext.ServerSideGridTests.Single(e.Row)BindingSource.Clear()BindingSource.Add(obj)EndSub
- MainForm.cs (VB:MainForm.vb)
(you will be redirected to DevExpress.com to submit your response)
About
Edit the focused grid row in DataLayoutControl in Server Mode.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.