We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Copy & Paste in DataBound grid

We need to implement the following in our application :- Capability to be present to copy data from one cell and paste it into another. Only one cell can be copied at a time, but can be copied into multiple cells. Kindly note that the data grid itself is non-editable.

6 Replies

AD Administrator Syncfusion Team July 14, 2004 08:04 AM UTC

One way you can do this is to handle the grid.KeyDown event and copy the currentcell at that point. Then handle the grid.Model.ClipboardPaste event, get the value from the clipboard and set it into any selected range. Here is a rough sample. Forum_CopyPaste_4723.zip


KK Kewalramani Kanchan July 20, 2004 07:19 AM UTC

Hi Clay: Thanks for your response. We could successfully implement the functionality of Copy & paste on cells on a ReadOnly grid. Going further on this, we are some problems for which we need your assistance again. 1. Only one cell can be copied at a time but can be copied into multiple cells. How do we achieve this ? In the current implementation, even if the user selects multiple cells and does a CTRL+C value from the cell that has focus is stored on the clipboard. But since the user can select multiple cells he gets an illusion that all the selected values are copied as in Excel. 2. User should not be allowed to delete data on the cells. This is a drawback when we set column as Static. Even though the user cannot make changes to the data, he can select some cells and hit the Delete key to clear the data. Originally we had set the column property to ReadOnly to prevent this behavior. Please note that we cannot disable the functionality of Delete key, since the user is allowed to select multiple rows are delete them from the grid. Just for your information we are using 3.5 version of Syncfusion grid for this particular application (as required by our client). Kindly suggest.


KK Kewalramani Kanchan July 20, 2004 07:23 AM UTC

The version of Syncfusion used is 1.6.1.8, extremely sorry about the confusion. >Hi Clay: > >Thanks for your response. We could successfully implement the functionality of Copy & paste on cells on a ReadOnly grid. Going further on this, we are some problems for which we need your assistance again. >1. Only one cell can be copied at a time but can be copied into multiple cells. How do we achieve this ? In the current implementation, even if the user selects multiple cells and does a CTRL+C value from the cell that has focus is stored on the clipboard. But since the user can select multiple cells he gets an illusion that all the selected values are copied as in Excel. >2. User should not be allowed to delete data on the cells. This is a drawback when we set column as Static. Even though the user cannot make changes to the data, he can select some cells and hit the Delete key to clear the data. Originally we had set the column property to ReadOnly to prevent this behavior. >Please note that we cannot disable the functionality of Delete key, since the user is allowed to select multiple rows are delete them from the grid. >Just for your information we are using 3.5 version of Syncfusion grid for this particular application (as required by our client). >Kindly suggest. >


AD Administrator Syncfusion Team July 20, 2004 07:51 AM UTC

1) Try handling the grid.Model.SelectionsChanging event. If e.range.IsCells && (e.Range.Width > 1 || e.Range.Height > 1), then set e.Cancel = ture. This should prevent the user from selecting more than one cell. 2) Did you try setting style.ReadOnly for the column whose style.CellType is ''Static"? In 2.0, this would prevent the delete from working, but I am not sure about 1.6.1.8. Anyway, you can handle the grid.Model.CellsClearing event and set e.Cancel = true if the range includes cells you do not want to clear.


KK Kewalramani Kanchan July 20, 2004 09:03 AM UTC

Hey Clay: The solution suggested for point 1 works fine. In response to point 2 – If we set the column to ReadOnly then the feature of pasting the data from clipboard cannot be achieved. Also, we were unable to implement the alternative solution suggested to use grid.Model.CellsClearing. Actually, in 1.6.1.8 the event provided is Model_ClearingCells which doesnot support the e.Cancel property. Kindly suggest. Thanks for your support.


AD Administrator Syncfusion Team July 20, 2004 11:39 AM UTC

Try setting ReadOnly = true again. Then when you do the pasting, set grid.IgnoreReadOnly = true. (Might be grid.Model.IgnoreReadOnly = true). Don''t forget to set it back after the paste. This may allow the readonly to prevent the clearing, but let the pasting go through.

Loader.
Live Chat Icon For mobile
Up arrow icon