private void RowDragDropController_Drop(object sender, GridRowDropEventArgs e) { var droppedIndex = (int)e.TargetRecord; var rowIndex = this.sfDataGrid.ResolveToRowIndex(droppedIndex); NodeEntry recordEntry = null; if (this.sfDataGrid.View.TopLevelGroup != null) { recordEntry = this.sfDataGrid.View.TopLevelGroup.DisplayElements[this.sfDataGrid.ResolveToRecordIndex(rowIndex)]; } else { recordEntry = this.sfDataGrid.View.Records[this.sfDataGrid.ResolveToRecordIndex(rowIndex)]; } var targetRecord = ((recordEntry as RecordEntry).Data as OrderInfo); txtDisplayRecord.Text = "OrderId : " + targetRecord.OrderID + "\nCustomerID : " + targetRecord.CustomerID + "\nCustomerName : " + targetRecord.CustomerName + "\nCountry : " + targetRecord.Country + "\nUnitPrice : " + targetRecord.UnitPrice + "\nRow Index :" + droppedIndex; }
/// <summary> /// Customize the Drop event.restrict the certain record and Drop position from drop. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sfDataGrid_Drop(object sender, GridRowDropEventArgs e) { if (e.IsFromOutSideSource) { var draggingRecord = e.Data.GetData("Nodes") as ObservableCollection <TreeNode>; var record = draggingRecord[0].Item as EmployeeInfo; int dropIndex = (int)e.TargetRecord; var dropPosition = e.DropPosition.ToString(); if (record.Title == "Manager") { e.Handled = true; return; } IList collection = null; collection = AssociatedObject.sfDataGrid.View.SourceCollection as IList; if (dropPosition == "DropAbove") { dropIndex--; collection.Insert(dropIndex, record); } else { dropIndex++; collection.Insert(dropIndex, record); } AssociatedObject.sfTreeGrid.View.Remove(record); e.Handled = true; } }