コード例 #1
0
ファイル: ContentsView.cs プロジェクト: calbonaler/Comical
 private void dgvImages_RowMoving(object sender, Controls.RowMovingEventArgs e)
 {
     if (e.Source == dgvImages)
     {
         _images.MoveRange(e.SourceRows[0].Index, e.SourceRows.Count, e.Destination);
     }
 }
コード例 #2
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            if (drgevent == null || !drgevent.Data.GetDataPresent(typeof(DataGridViewMovedRows)) || HitRowIndex < 0)
            {
                base.OnDragDrop(drgevent);
                return;
            }
            int newIndex = GetDragHitTestInfo(drgevent).ActualDestination;

            if (newIndex < 0)
            {
                return;
            }
            var dgdo = (DataGridViewMovedRows)drgevent.Data.GetData(typeof(DataGridViewMovedRows));
            RowMovingEventArgs ev = new RowMovingEventArgs(dgdo.Source, dgdo.SourceRows, dgdo.SetRow, newIndex);

            OnRowMoving(ev);
            if (!ev.Cancel)
            {
                foreach (var row in dgdo.SourceRows)
                {
                    dgdo.Source.Rows.Remove(row);
                }
                Rows.InsertRange(newIndex, dgdo.GetModifiedRows());
                ClearSelection();
                for (int i = newIndex; i < newIndex + dgdo.SourceRows.Count; i++)
                {
                    SetSelectedRowCore(i, true);
                }
                OnRowMoved(EventArgs.Empty);
            }
            HitRowIndex = -1;
        }
コード例 #3
0
 private void dgvBookmarks_RowMoving(object sender, Controls.RowMovingEventArgs e)
 {
     if (e.Source.Name == "dgvImages")
     {
         e.Cancel = true;
         _bookmarks.Insert(e.Destination, new Bookmark()
         {
             Target = e.SourceRows[0].Index
         });
     }
     else if (e.Source == dgvBookmarks)
     {
         _bookmarks.Move(e.SourceRows[0].Index, e.Destination);
     }
 }
コード例 #4
0
		/// <summary><see cref="RowMoving"/> イベントを発生させます。</summary>
		protected virtual void OnRowMoving(RowMovingEventArgs e) { RowMoving?.Invoke(this, e); }
コード例 #5
0
		protected override void OnDragDrop(DragEventArgs drgevent)
		{
			if (drgevent == null || !drgevent.Data.GetDataPresent(typeof(DataGridViewMovedRows)) || HitRowIndex < 0)
			{
				base.OnDragDrop(drgevent);
				return;
			}
			int newIndex = GetDragHitTestInfo(drgevent).ActualDestination;
			if (newIndex < 0)
				return;
			var dgdo = (DataGridViewMovedRows)drgevent.Data.GetData(typeof(DataGridViewMovedRows));
			RowMovingEventArgs ev = new RowMovingEventArgs(dgdo.Source, dgdo.SourceRows, dgdo.SetRow, newIndex);
			OnRowMoving(ev);
			if (!ev.Cancel)
			{
				foreach (var row in dgdo.SourceRows)
					dgdo.Source.Rows.Remove(row);
				Rows.InsertRange(newIndex, dgdo.GetModifiedRows());
				ClearSelection();
				for (int i = newIndex; i < newIndex + dgdo.SourceRows.Count; i++)
					SetSelectedRowCore(i, true);
				OnRowMoved(EventArgs.Empty);
			}
			HitRowIndex = -1;
		}
コード例 #6
0
 /// <summary><see cref="RowMoving"/> イベントを発生させます。</summary>
 protected virtual void OnRowMoving(RowMovingEventArgs e)
 {
     RowMoving?.Invoke(this, e);
 }