Duplicates a bound or unbound
DataGridView
in an unbound DataGridView.
Namespace: CleanCode.FormsAssembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
public static void DuplicateGridView(
DataGridView sourceDGV,
DataGridView destDGV
)
Public Shared Sub DuplicateGridView ( _
sourceDGV As DataGridView, _
destDGV As DataGridView _
)
public:
static void DuplicateGridView(
DataGridView^ sourceDGV,
DataGridView^ destDGV
)
This method creates a copy of a DataGridView,
and replacing the source DataGridView on its parent form.
The source DataGridView is simply hidden;
it is not deleted.
The set of properties that are duplicated are taken from the
suggestions at the unbound datagrid walk-through at
Creating an Unbound Windows Forms DataGridView Control.
While one could actually just add columns to a bound DataGridView
and fill in the data there, that approach has (at least)
two drawbacks. First, one could not sort on the new columns.
Second, sorting on one of the original columns drops all the data
in the new columns.