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 bd2256d

Browse files
ES-976509 - Resolve the ReadMe file in the sample repository
1 parent b5b1efc commit bd2256d

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

DataGridWhileDraggingTheRecord.png

41.4 KB
Loading

GettingTargetedRecordOnDrop.png

46.5 KB
Loading

README.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
1-
# How to get the target record when drop the row in WPF DataGrid(SfDataGrid)?
2-
3-
## About the sample
1+
# How to Get the Target Record when Drop the Row in WPF DataGrid?
42

53
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)?
64

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
```
26+
#### Dragging:
27+
![alt text](DataGridWhileDraggingTheRecord.png)
3128

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
29+
#### After Drop:
30+
![alt text](GettingTargetedRecordOnDrop.png)

0 commit comments

Comments
 (0)