WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a8eae0f

Browse files
authored
Merge pull request #4 from SyncfusionExamples/ES-976509
ES-976509 - Resolve the ReadMe file in the sample repository
2 parents b5b1efc + 7c21948 commit a8eae0f

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

GettingTargetedRecordOnDrop.gif

448 KB
Loading

README.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
1-
# How to get the target record when drop the row in WPF DataGrid(SfDataGrid)?
1+
# How to Get the Target Record when Drop the Row in WPF DataGrid?
22

3-
## About the sample
3+
This example illustrates how to get the target record when drop the row in [WPF DataGrid](https://www.syncfusion.com/wpf-controls/datagrid) (SfDataGrid).
44

5-
This example illustrates how to get the target record when drop the row in [WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid) (SfDataGrid)?
6-
7-
[WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid) (SfDataGrid) does not provide the direct support to get the target record which is going to drop. You can get the target record which is going to drop by using [SfDataGrid.RowDragDropController.Drop](https://help.syncfusion.com/cr/cref_files/wpf/Syncfusion.SfGrid.WPF~Syncfusion.UI.Xaml.Grid.GridRowDragDropController~Drop_EV.html) event.
5+
`DataGrid` does not provide the direct support to get the target record which is going to drop. You can get the target record which is going to drop by using [SfDataGrid.RowDragDropController.Drop](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.GridRowDragDropController.html#Syncfusion_UI_Xaml_Grid_GridRowDragDropController_Drop) event.
86

97
```C#
108
sfDataGrid.RowDragDropController.Drop += RowDragDropController_Drop;
119

1210
private void RowDragDropController_Drop(object sender, GridRowDropEventArgs e)
1311
{
14-
var droppedIndex = (int)e.TargetRecord;
15-
16-
var rowIndex = this.sfDataGrid.ResolveToRowIndex(droppedIndex);
17-
18-
NodeEntry recordEntry = null;
19-
20-
if (this.sfDataGrid.View.TopLevelGroup != null)
21-
recordEntry = this.sfDataGrid.View.TopLevelGroup.DisplayElements[this.sfDataGrid.ResolveToRecordIndex(rowIndex)];
22-
else
23-
recordEntry = this.sfDataGrid.View.Records[this.sfDataGrid.ResolveToRecordIndex(rowIndex)];
24-
25-
var targetRecord = ((recordEntry as RecordEntry).Data as OrderInfo);
26-
27-
txtDisplayRecord.Text = "OrderId : " + targetRecord.OrderID + "\nCustomerID : " + targetRecord.CustomerID + "\nCustomerName : " + targetRecord.CustomerName + "\nCountry : " + targetRecord.Country + "\nUnitPrice : " + targetRecord.UnitPrice + "\nRow Index :" + droppedIndex;
12+
var droppedIndex = (int)e.TargetRecord;
13+
var rowIndex = this.sfDataGrid.ResolveToRowIndex(droppedIndex);
14+
NodeEntry recordEntry = null;
15+
16+
if (this.sfDataGrid.View.TopLevelGroup != null)
17+
recordEntry = this.sfDataGrid.View.TopLevelGroup.DisplayElements[this.sfDataGrid.ResolveToRecordIndex(rowIndex)];
18+
else
19+
recordEntry = this.sfDataGrid.View.Records[this.sfDataGrid.ResolveToRecordIndex(rowIndex)];
20+
21+
var targetRecord = ((recordEntry as RecordEntry).Data as OrderInfo);
22+
23+
txtDisplayRecord.Text = "OrderId : " + targetRecord.OrderID + "\nCustomerID : " + targetRecord.CustomerID + "\nCustomerName : " + targetRecord.CustomerName + "\nCountry : " + targetRecord.Country + "\nUnitPrice : " + targetRecord.UnitPrice + "\nRow Index :" + droppedIndex;
2824
}
29-
3025
```
3126

32-
KB article - [How to get the target record when drop the row in WPF DataGrid(SfDataGrid)?](https://www.syncfusion.com/kb/11377/how-to-get-the-target-record-when-drop-the-row-in-wpf-datagrid-sfdatagrid)
33-
34-
## Requirements to run the demo
35-
Visual Studio 2015 and above versions
27+
![Getting target record when drop and drop the row](GettingTargetedRecordOnDrop.gif)

0 commit comments

Comments
 (0)