protected async Task OnRowDraggedAsync(RowDragEventArgs args) { try { if (ListContext == null) { throw new InvalidOperationException(); } var editContext = ListContext.EditContexts.FirstOrDefault(x => x.Entity.Id == args.SubjectId); if (editContext == null) { throw new InvalidOperationException(); } editContext.NotifyReordered(args.TargetId); ListContext.EditContexts.Remove(editContext); if (args.TargetId == null) { ListContext.EditContexts.Add(editContext); } else { ListContext.EditContexts.Insert( ListContext.EditContexts.FindIndex(x => x.Entity.Id == args.TargetId), editContext); } await SetSectionsAsync(ListContext); StateHasChanged(); } catch (Exception ex) { HandleException(ex); } }
private void MainGrid_RowDrag(object sender, RowDragEventArgs e) { GridEXRow row = this.MainGrid.GetRow(); if (row != null && row.RowType == RowType.Record && row.DataRow != null) { System.Windows.Forms.DataObject dataObject = new System.Windows.Forms.DataObject(); dataObject.SetData(new TickerString((string)row.Cells["Ticker"].Value)); GridEXColumn gridEXColumn = this.MainGrid.ColumnFromPoint(); if (gridEXColumn != null) { if (gridEXColumn.DataMember == "Ticker" || System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Control) { string[] array = ( from x in this.MainGrid.RootTable.Columns.OfType<GridEXColumn>() where x.Visible orderby x.Position select this.GetRTDString((string)row.Cells["Ticker"].Value, x.DataMember)).ToArray<string>(); array[0] = (string)row.Cells["Ticker"].Value; dataObject.SetData(System.Windows.Forms.DataFormats.Text, string.Join("\t", array)); } else { dataObject.SetData(System.Windows.Forms.DataFormats.Text, this.GetRTDString((string)row.Cells["Ticker"].Value, gridEXColumn.DataMember)); } } this.MainGrid.DoDragDrop(dataObject, System.Windows.Forms.DragDropEffects.Copy); } }