Skip to content

Commit cd8e702

Browse files
authored
Update Readme.md
1 parent 22fa119 commit cd8e702

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

Readme.md

+18-31
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,45 @@
33
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T868102)
44
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
55
<!-- default badges end -->
6-
<!-- default file list -->
7-
*Files to look at*:
86

9-
* **[MainForm.cs](./CS/BindingListForServerMode/MainForm.cs) (VB: [MainForm.vb](./VB/BindingListForServerMode/MainForm.vb))**
10-
<!-- default file list end -->
11-
# Server Mode - How to edit a focused GridView row in DataLayoutControl
7+
# WinForms Data Grid - Edit the focused row in DataLayoutControl in Server Mode
128

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 data sources except for [XPServerCollectionSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPServerCollectionSource) are read-only.
1410

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.
1612

1713
## Implementation details
1814

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.
2016
- If your ORM is XPO, add the [XPBindingSource](https://docs.devexpress.com/XPO/DevExpress.Xpo.XPBindingSource) component from the toolbox.
2117
1. Rebuild the project.
2218
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.
2420
- 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.
2521
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.
2723
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.
30-
2. [Retrieve 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).
31-
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.
3329

34-
### A code example for XPBindingSource
35-
36-
<details>
37-
<summary>C#</summary>
30+
### Example: XPBindingSource
3831

3932
```cs
4033
private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) {
4134
XPBindingSource.DataSource = Session.GetLoadedObjectByKey<ServerSideGridTest>(e.Row);
4235
}
4336
```
44-
</details>
45-
<details>
46-
<summary>VB.NET</summary>
4737

4838
```vb
4939
Private Sub GridView_FocusedRowObjectChanged(ByVal sender As Object, ByVal e As FocusedRowObjectChangedEventArgs)
5040
XPBindingSource.DataSource = Session.GetLoadedObjectByKey(Of ServerSideGridTest)(e.Row)
5141
End Sub
5242
```
53-
</details>
54-
55-
### A code example for BindingSource
5643

57-
<details>
58-
<summary>C#</summary>
44+
### Example: BindingSource
5945

6046
```cs
6147
private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectChangedEventArgs e) {
@@ -64,9 +50,6 @@ private void GridView_FocusedRowObjectChanged(object sender, FocusedRowObjectCha
6450
BindingSource.Add(obj);
6551
}
6652
```
67-
</details>
68-
<details>
69-
<summary>VB.NET</summary>
7053

7154
```vb
7255
Private Sub GridView_FocusedRowObjectChanged(ByVal sender As Object, ByVal e As FocusedRowObjectChangedEventArgs)
@@ -75,4 +58,8 @@ Private Sub GridView_FocusedRowObjectChanged(ByVal sender As Object, ByVal e As
7558
BindingSource.Add(obj)
7659
End Sub
7760
```
78-
</details>
61+
62+
63+
## Files to Review
64+
65+
* [MainForm.cs](./CS/BindingListForServerMode/MainForm.cs) (VB: [MainForm.vb](./VB/BindingListForServerMode/MainForm.vb))

0 commit comments

Comments
 (0)