Beispiel #1
0
        private void MoveRows(RadGridView targetGrid, RadGridView dragGrid, List <GridViewRowInfo> dragRows, int index)
        {
            dragGrid.BeginUpdate();
            targetGrid.BeginUpdate();
            for (int i = dragRows.Count - 1; i >= 0; i--)
            {
                GridViewRowInfo row = dragRows[i];
                if (row is GridViewSummaryRowInfo)
                {
                    continue;
                }
                if (targetGrid.DataSource == null)
                {
                    //unbound scenario
                    GridViewRowInfo newRow = targetGrid.Rows.NewRow();
                    foreach (GridViewCellInfo cell in row.Cells)
                    {
                        if (newRow.Cells[cell.ColumnInfo.Name] != null)
                        {
                            newRow.Cells[cell.ColumnInfo.Name].Value = cell.Value;
                        }
                    }

                    targetGrid.Rows.Insert(index, newRow);

                    row.IsSelected = false;
                    dragGrid.Rows.Remove(row);
                }
                else if (typeof(DataSet).IsAssignableFrom(targetGrid.DataSource.GetType()))
                {
                    //bound to a dataset scenario
                    var sourceTable = ((DataSet)dragGrid.DataSource).Tables[0];
                    var targetTable = ((DataSet)targetGrid.DataSource).Tables[0];

                    var newRow = targetTable.NewRow();
                    foreach (GridViewCellInfo cell in row.Cells)
                    {
                        newRow[cell.ColumnInfo.Name] = cell.Value;
                    }

                    sourceTable.Rows.Remove(((DataRowView)row.DataBoundItem).Row);
                    targetTable.Rows.InsertAt(newRow, index);
                }
                else if (typeof(IList).IsAssignableFrom(targetGrid.DataSource.GetType()))
                {
                    //bound to a list of objects scenario
                    var targetCollection = (IList)targetGrid.DataSource;
                    var sourceCollection = (IList)dragGrid.DataSource;
                    sourceCollection.Remove(row.DataBoundItem);
                    targetCollection.Add(row.DataBoundItem);
                }
                else
                {
                    throw new ApplicationException("Unhandled Scenario");
                }
                index++;
            }
            dragGrid.EndUpdate(true);
            targetGrid.EndUpdate(true);
        }
Beispiel #2
0
        private void MoveRows(RadGridView dragGrid,
                              GridViewRowInfo dragRow, int index)
        {
            dragGrid.BeginUpdate();

            GridViewRowInfo row = dragRow;

            if (row is GridViewSummaryRowInfo)
            {
                return;
            }
            if (dragGrid.DataSource != null && typeof(System.Collections.IList).IsAssignableFrom(dragGrid.DataSource.GetType()))
            {
                //bound to a list of objects scenario
                var sourceCollection = (System.Collections.IList)dragGrid.DataSource;
                if (row.Index < index)
                {
                    index--;
                }
                sourceCollection.Remove(row.DataBoundItem);
                sourceCollection.Insert(index, row.DataBoundItem);
            }
            else
            {
                throw new ApplicationException("Unhandled Scenario");
            }

            dragGrid.EndUpdate(true);
        }
Beispiel #3
0
 internal static void UpdateSize(RadGridView gridView)
 {
     gridView.BeginUpdate();
     for (int i = 0; i < gridView.RowCount; i++)
     {
         long size = (long)gridView.Rows[i].Cells["Size"].Value;
         gridView.Rows[i].Cells["Size"].Value = size + size;
     }
     gridView.EndUpdate();
     gridView.BeginUpdate();
     for (int i = 0; i < gridView.RowCount; i++)
     {
         long size = (long)gridView.Rows[i].Cells["Size"].Value;
         gridView.Rows[i].Cells["Size"].Value = size / 2;
     }
     gridView.EndUpdate();
 }
Beispiel #4
0
 internal static void UpdateSID(RadGridView gridView)
 {
     gridView.BeginUpdate();
     for (int i = 0; i < gridView.RowCount; i++)
     {
         string sid = (string)gridView.Rows[i].Cells["SID"].Value;
         gridView.Rows[i].Cells["SID"].Value = "#" + sid;
     }
     gridView.EndUpdate();
     gridView.BeginUpdate();
     for (int i = 0; i < gridView.RowCount; i++)
     {
         string sid = (string)gridView.Rows[i].Cells["SID"].Value;
         gridView.Rows[i].Cells["SID"].Value = sid.Substring(1);
     }
     gridView.EndUpdate();
 }
        //, GridRowElement rowElement)
        /// <summary>
        /// The move rows.
        /// </summary>
        /// <param name="targetGrid">
        /// The target grid.
        /// </param>
        /// <param name="dragGrid">
        /// The drag grid.
        /// </param>
        /// <param name="dragRows">
        /// The drag rows.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        private void MoveRows(RadGridView targetGrid, RadGridView dragGrid, GridCellElement cellElement)
        {
            dragGrid.BeginUpdate();
            targetGrid.BeginUpdate();

            Console.WriteLine("HERE!");
            targetGrid.Rows[cellElement.RowIndex].Cells[cellElement.ColumnIndex].Value = "blq";

            dragGrid.EndUpdate(true);
            targetGrid.EndUpdate(true);
        }
        /// <summary>
        /// The move rows.
        /// </summary>
        /// <param name="targetGrid">
        /// The target grid.
        /// </param>
        /// <param name="dragGrid">
        /// The drag grid.
        /// </param>
        /// <param name="dragRows">
        /// The drag rows.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        private void MoveCell(RadGridView targetGrid, RadGridView dragGrid, GridCellElement cellElement, int index, int indexRow, int indexColumn)
        {
            dragGrid.BeginUpdate();
            targetGrid.BeginUpdate();

            if (targetGrid != null)
            {
                targetGrid.Rows[indexRow].Cells[indexColumn].Value = cellElement.Value;
                targetGrid.Rows[indexRow].Cells[indexColumn].Tag = cellElement.Tag;

                dragGrid.Rows[cellElement.RowIndex].Cells[cellElement.ColumnIndex].Value = "";
                dragGrid.Rows[cellElement.RowIndex].Cells[cellElement.ColumnIndex].Tag = null;
            }

            dragGrid.EndUpdate(true);
            targetGrid.EndUpdate(true);
        }