You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Server Mode - How to edit a focused GridView row in DataLayoutControl
7
+
# WinForms Data Grid - Edit the focused row in DataLayoutControl in Server Mode
12
8
13
-
The standard approach (binding the GridControl and DataLayoutControl to the same collection) does not work in this scenario, because CurrencyManager does not manage [Server Mode Data Sources](https://docs.devexpress.com/WindowsForms/8398/Controls-and-Libraries/Data-Grid/Data-Binding/Large-Data-Sources-Server-and-Instant-Feedback-Modes#server-mode-data-sources). In addition, all [Server Mode Data Sources](https://docs.devexpress.com/WindowsForms/8398/Controls-and-Libraries/Data-Grid/Data-Binding/Large-Data-Sources-Server-and-Instant-Feedback-Modes#server-mode-data-sources) except for [XPServerCollectionSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPServerCollectionSource) are read-only.
9
+
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 manage [Server Mode Data Sources](https://docs.devexpress.com/WindowsForms/8398/Controls-and-Libraries/Data-Grid/Data-Binding/Large-Data-Sources-Server-and-Instant-Feedback-Modes#server-mode-data-sources). All Server Mode datasources except for [XPServerCollectionSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPServerCollectionSource) are read-only.
14
10
15
-
This example demonstrates how to use the [FocusedRowChanged](https://docs.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.ColumnView.FocusedRowObjectChanged) event to synchronize the DataLayoutControl's data source ([XPBindingSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPBindingSource) or [BindingSource](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.bindingsource)) with a focused row.
11
+
This example handles the [FocusedRowChanged](https://docs.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.ColumnView.FocusedRowObjectChanged) event to synchronize the DataLayoutControl's data source ([XPBindingSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPBindingSource) or [BindingSource](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.bindingsource)) with the focused row in the GridControl.
16
12
17
13
## Implementation details
18
14
19
-
1. Bind DataLayoutControl to a data source in the visual designer.
15
+
1. Bind the `DataLayoutControl` to a data source in the Visual Studio Designer.
20
16
- If your ORM is XPO, add the [XPBindingSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPBindingSource) component from the toolbox.
21
17
1. Rebuild the project.
22
18
2. Select the [XPBindingSource.ObjectClassInfo](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPBindingSource.ObjectClassInfo) property in the Properties window, open the drop-down list, and choose an appropriate XPO class.
23
-
3. Assign XPBindingSource to the [DataLayoutControl.DataSource](https://docs.devexpress.com/WindowsForms/DevExpress.XtraDataLayout.DataLayoutControl.DataSource) property.
19
+
3. Assign `XPBindingSource` to the [DataLayoutControl.DataSource](https://docs.devexpress.com/WindowsForms/DevExpress.XtraDataLayout.DataLayoutControl.DataSource) property.
24
20
- If your ORM is EF or a different library, add the [BindingSource](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.bindingsource) component from the toolbox.
25
21
1. Rebuild the project.
26
-
2. Click the **Project>Add New Data Source** menu item.
22
+
2. Click the **Project > Add New Data Source** menu item.
27
23
3. Choose the Object Data Source Type and click Next.
28
-
4. Choose an appropriate class in the list and click Finish.
29
-
5. Assign BindingSource to the [DataLayoutControl.DataSource](https://docs.devexpress.com/WindowsForms/DevExpress.XtraDataLayout.DataLayoutControl.DataSource) property.
3. Select GridView and subscribe to the [FocusedRowChanged](https://docs.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.ColumnView.FocusedRowObjectChanged) event.
32
-
4. Use the **FocusedRowChangedEventArgs.Row** property value to retrieve a focused object and add it to the data source.
24
+
4. Choose an appropriate class in the list and click **Finish**.
25
+
5. Assign `BindingSource` to the [DataLayoutControl.DataSource](https://docs.devexpress.com/WindowsForms/DevExpress.XtraDataLayout.DataLayoutControl.DataSource) property.
26
+
2.[Retrieve data fields](https://docs.devexpress.com/WindowsForms/4921/controls-and-libraries/form-layout-managers/layout-and-data-layout-controls/data-layout-control#step-2-retrieve-fields).
27
+
3. Select the `GridView` and subscribe to the [FocusedRowChanged](https://docs.devexpress.com/WindowsForms/DevExpress.XtraGrid.Views.Base.ColumnView.FocusedRowObjectChanged) event.
28
+
4. Use the `e.Row` property to obtain a data object that corresponds to the focused row and add it to the data source.
0 commit comments