public void ShouldPaseIntoColumnsWith_VisibleFalse()
        {
            Grid grid1 = new Grid();

            grid1.Redim(6, 4);

            grid1[0, 0] = new SourceGrid.Cells.Cell("a");
            grid1[0, 1] = new SourceGrid.Cells.Cell("b");
            grid1[0, 2] = new SourceGrid.Cells.Cell("c");
            grid1[0, 3] = new SourceGrid.Cells.Cell("d");


            RangeData data = RangeData.LoadData(grid1, new Range(0, 0, 0, 3), CutMode.None);


            grid1.Columns[1].Visible = false;
            grid1[1, 0] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 1] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 2] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 3] = new SourceGrid.Cells.Cell("x", typeof(string));

            data.WriteData(grid1, new Position(1, 0));
            Assert.AreEqual("a", grid1[1, 0].Value);
            Assert.AreEqual("b", grid1[1, 1].Value);
            Assert.AreEqual("c", grid1[1, 2].Value);
            Assert.AreEqual("d", grid1[1, 3].Value);
        }
Esempio n. 2
0
        private void grid_KeyDown(GridVirtual sender, KeyEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            Range rng = sender.Selection.BorderRange;

            if (rng.IsEmpty())
            {
                return;
            }

            //Paste
            if (e.Control && e.KeyCode == Keys.V)
            {
                RangeData rngData = RangeData.ClipboardGetData();

                if (rngData != null)
                {
                    Range destinationRange = rngData.FindDestinationRange(sender, rng.Start);
                    if (ExpandSelection == false)
                    {
                        destinationRange = destinationRange.Intersect(rng);
                    }

                    rngData.WriteData(sender, destinationRange);
                    e.Handled = true;
                    sender.Selection.Clear();
                    sender.Selection.Add(destinationRange);
                }
            }
            //Copy
            else if (e.Control && e.KeyCode == Keys.C)
            {
                RangeData data = new RangeData();
                data.LoadData(sender, rng, rng.Start, CutMode.None);
                RangeData.ClipboardSetData(data);

                e.Handled = true;
            }
            //Cut
            else if (e.Control && e.KeyCode == Keys.X && EnableCutData)
            {
                RangeData data = new RangeData();
                data.LoadData(sender, rng, rng.Start, CutMode.CutImmediately);
                RangeData.ClipboardSetData(data);

                e.Handled = true;
            }
        }
Esempio n. 3
0
        protected virtual void grid_DragDrop(GridVirtual sender, DragEventArgs e)
        {
            if (mRangeData != null)
            {
                Range destination = mHighlightedRange.Range;

                //Solo se il range sorgente è diverso dal range di destinazione
                if (mRangeData.SourceGrid != sender || mRangeData.SourceRange != destination)
                {
                    mRangeData.WriteData(sender, destination);
                    sender.Selection.Focus(destination.Start);
                    sender.Selection.Add(destination);
                }
            }

            ResetTempData();
        }
        public void PasteVertically()
        {
            Grid grid1 = new Grid();

            grid1.Redim(6, 3);

            grid1[0, 0] = new SourceGrid.Cells.Cell("a");
            grid1[1, 0] = new SourceGrid.Cells.Cell("b");
            grid1[2, 0] = new SourceGrid.Cells.Cell("c");


            RangeData data = RangeData.LoadData(grid1, new Range(0, 0, 2, 0), CutMode.None);


            grid1.Columns[1].Visible = false;
            grid1[0, 1] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[1, 1] = new SourceGrid.Cells.Cell("x", typeof(string));
            grid1[2, 1] = new SourceGrid.Cells.Cell("x", typeof(string));

            data.WriteData(grid1, new Position(0, 1));
            Assert.AreEqual("a", grid1[0, 1].Value);
            Assert.AreEqual("b", grid1[1, 1].Value);
            Assert.AreEqual("c", grid1[2, 1].Value);
        }