In most cases the developer defines the "hard" column set and does not expect that the user can change it by adding new columns. If we allow the user to paste data and extend the grid automatically to accommodate all pasted data, there is a high probability that the user will add new columns to the grid and change the structure of the grid - which may lead to improper functioning of the app.
To process all these situations, I think, iGrid should provide the developer with the ability to allow the automatic adding of columns/rows while pasting data. However, this functionality must be disabled by default - which, as I explained, is the expected behavior of iGrid in most cases. To enable this thing, iGrid can raise an event named, say, BeforePaste with the following arguments:
BeforePaste(ByVal lColsToAdd As Long, ByVal lRowsToAdd As Long, ByRef bDoDefault As Boolean)
Note that in contrast to many other events providing the bDoDefault parameter, this parameter will be set to False by default. If iGrid needs more columns/rows to accommodate the pasted data, lColsToAdd and/or lRowsToAdd will be greater than 0. The developer can analyze these values in the event handler and allow columns/rows addition explicitly by setting bDoDefault to True, or prohibit this action by doing nothing or even display a warning telling why the data can't be pasted.
As an alternative, we can provide an enumeration with the following 3 values instead of bDoDefault:
- Do nothing
- Paste data, but clip them if column/rows are not enough
- Paste data and extend the grid if required
One more alternative - to provide two Boolean parameters passed by reference that will allow to enable adding columns and rows separately:
BeforePaste(ByVal lColsToAdd As Long, ByVal lRowsToAdd As Long, _
ByRef bAddCols As Boolean, ByRef bAddRows As Boolean)
The idea is that the developer may allow adding rows dynamically on CTRL+V, but not adding columns.
As one more feature, we can add the bDoDefault parameter to the last event signature, but this parameter will enable/disable pasting data as a whole operation:
BeforePaste(ByVal lColsToAdd As Long, ByVal lRowsToAdd As Long, _
ByRef bDoDefault As Boolean, ByRef bAddCols As Boolean, ByRef bAddRows As Boolean)
Having this "classical" iGrid's bDoDefault parameter and bAddCols/bAddRows, you will be able to implement any behavior needed at pasting data - not to paste data at all, paste data but do not enlarge iGrid, paste data and add only rows on-the-fly, and so on.
How about that?
Edited by user
2018-06-11T09:03:52Z
|
Reason: Not specified