DataGridCutPasteHandler ClassCleanCode C# Libraries v1.2.03 API
Supports cut and paste operations in a OnlineDataGridView at the cell focus level rather than at the cell-input focus level.
Inheritance Hierarchy

OnlineSystem Object
  CleanCode.Forms DataGridCutPasteHandler

Namespace: CleanCode.Forms
Assembly: CleanCode (in CleanCode.dll) Version: (1.2.03)

public sealed class DataGridCutPasteHandler

DataGridView controls have built-in support for cut, copy, and paste once you have given input focus to an individual cell. That requires first clicking the cell to select it (cell focus), then clicking again to give that cell input focus (cell-input focus). The issues with that are:
  • it takes 2 clicks rather than 1.
  • you may only operate on a single cell at a time.
The DataGridCutPasteHandler class addresses both of these drawbacks. Once you instrument your code properly, a single click on a cell will then allow you to use the standard Ctrl+C, Ctrl+V, and Ctrl+X operations, plus a function to duplicate a row via Ctrl+Shift+V.

The copy operation will copy multiple rows and columns if you have multiple cells selected. A subsequent paste will only affect cells that you have selected. So if you copied 5 cells across but then select a region that is 2 cells across, only the first 2 cells of data will be pasted. Similarly, if you select more cells than you have stored in the copy buffer, the paste will stop when the copy buffer is exhausted, leaving remaining selected cells untouched.

You may copy a region of cells that contains multiple rows and columns; however, only the cells in the first row will be used in any subsequent paste, subject to the rules above. If your selected paste region contains multiple rows, the paste will only be performed in the last row selected.

You may paste into multiple cells from an external source as well; embedded tabs in the text indicate cell boundaries.

Since CleanCode 0.9.07.

See Also