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

Limiting pasting area

Hi,

I'm looking at limiting the size of the pasting area.

If I take the FirstGroupingGrid as an example. If a user copy a column of 20 rows in Excel. Then paste it on one of the cell in the wins column. I want the pasting to stop as soon as it encounters a row with a different sport.

I’ve looked at the GridModel.ClipboardCanPaste event but it does not seem to contain the position of the pasting area.

Any help will be appreciated!

Thanks!

6 Replies

LS Lingaraj S Syncfusion Team July 28, 2009 12:39 PM UTC

Hi Stephane,

Thank you for your interest in Syncfusion product.

If you want to get the pasted range in the ClipboardCanPaste event, then please try using RangeList.ActiveRange property to achieve this behavior. If you want to cancel the Paste in GriGroupingControl, please try using Handled and Result property in GridGroupingControl to achieve this behavior.

Refer the code below:

------------C# Code----------------------------
this.gridGroupingControl1.TableModel.ClipboardCanPaste += new GridCutPasteEventHandler(TableModel_ClipboardCanPaste);
void TableModel_ClipboardCanPaste(object sender, GridCutPasteEventArgs e)
{
GridRangeInfo ran = e.RangeList.ActiveRange;
if (ran.Left != 2) // Pasting only allow with the second column
{
e.Handled = true;
e.Result = false;
}
}
---------VB Code------------------------
AddHandler gridGroupingControl1.TableModel.ClipboardCanPaste, AddressOf TableModel_ClipboardCanPaste
Private Sub TableModel_ClipboardCanPaste(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
Dim ran As GridRangeInfo = e.RangeList.ActiveRange
If ran.Left <> 2 Then ' Pasting only allow with the second column
e.Handled = True
e.Result = False
End If
End Sub


Please let me know if you have any queries.

Regards,
Lingaraj S.


S_ Stephane _ July 28, 2009 02:24 PM UTC

I tried this, no mater what I do I always have.

Bottom = 0
Height = 1
Left = 0
Right = 0
Top = 0
Width = 1



GGCControlVB_b2dfb2b3.zip


LS Lingaraj S Syncfusion Team July 30, 2009 03:08 PM UTC

Hi Stephane,

Sorry for the inconvenience caused.

The Selections.GetSelectedRange method is used to get the SelctedRangeList in GridGroupingControl. If you want to get the pasting area, then please try using ActiveRange property in selected GridRangeInfoList to solve the issue.

Refer the code below:

Private Sub TableModel_ClipboardCanPaste(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
Dim lis As GridRangeInfoList
Me.gridGroupingControl1.TableModel.Selections.GetSelectedRanges(lis, True)
If lis.ActiveRange.Left <> 2 Then
e.Handled = True
e.Result = False
End If
End Sub


Refer the sample in below link:
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/Forums/GGCControlMod.zip

Please let me know if you have any queries.

Regards.
Lingaraj S.


S_ Stephane _ July 30, 2009 05:23 PM UTC

The lis.ActiveRange seems to give me the current selected cell position not the pasting range.

If I copy a table 3x3 from Excel and paste it in the 2nd column, it will still paste on the other columns.

Is there something that will tell me: "You are curently pasting a set of data that contains 3 columns and 3 rows"
And then tell: "No, I just want to paste 2 columns and 2 rows. Ignore the rest"

Thanks!


LS Lingaraj S Syncfusion Team July 31, 2009 03:23 PM UTC

Hi Stephane,

Thank you for the update.

If you want to paste the Data based on the Clipboard text, then please try looping with clipboard text to achieve this behavior. I've attached a simple sample that illustrate this better.

Refer the sample in below link:
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/Forums/GGCControlMod1.zip

Please let me know if you have any queries.

Regards,
Lingaraj S.


S_ Stephane _ July 31, 2009 05:32 PM UTC

Thanks!!

This also fix an other problem I had of knowing when the paste start and when it had finish pasting the data.

Loader.
Live Chat Icon For mobile
Up arrow icon