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.
Unfortunately, activation email could not send to your email. Please try again.

detecting cut,copy and paste on grid

Thread ID:

Created:

Updated:

Platform:

Replies:

118421 Mar 6,2015 08:37 AM Mar 16,2015 02:03 PM Windows Forms 7
loading
Tags: GridControl
vs
Asked On March 6, 2015 08:37 AM

Would like to have some information on following. Thanks in advance.

1. How to allow cell copy and disable row copy (similarly paste as well). Couldnt find anything from these can be differentiated. The event on can copy have same values in both cases.[ when result is set to false and handled to true on cancopy event's arg, copy from cell is also disabled]

2. How to disable cut, allow copy and paste?

Regards,
VS

Solai A L [Syncfusion]
Replied On March 6, 2015 06:05 PM

Hi VS,

Thank you for your interest in Syncfusion Products.

We don’t have any specific property to enable/disable the copy paste functionality. In order to achieve your requirement, you can have a Boolean property and dynamically you can change the Boolean value and accordingly those copy paste events can be fired. If your requirement is different from this please provide us a screenshot or video file or simple sample. So, that it would be easy for us to provide prompt solution.

Please let us know if you have any other concerns.

Thanks & Regards,

AL.Solai.


vs
Replied On March 9, 2015 02:56 AM

Hi,
Thanks for the response, please see below comments.

On your answer for query 2,
"...he Boolean value and accordingly those copy paste events can be fired. If .." 
You are mentioning about the update on copy paste event as shown below right?
void m_grid_ClipboardCanCopy(object sender, GridCutPasteEventArgs e)
{
//allow copy
e.Result = true;
e.Handled = true;
/*
//disable copy
e.Result = false;
e.Handled = true;

*/
}

On query 1,
I want to allow copy of a cell and disallow copy of the complete row even if user try to do that. For that I need to know differentiate the two scenarios in the CanCopy event handler fn void m_grid_ClipboardCanCopy(object sender, GridCutPasteEventArgs e). How I can do it? The fields in GridCutPasteEventArgs have same values when I checked in both the cases. The isRow field was always set.

Thanks,
VS



Neelakandan Kannan [Syncfusion]
Replied On March 10, 2015 03:31 PM

Hi VS,

 

Thank you for your update.

 

If you want to disable the row being copied from grid, you can use ClipboardCanCopy event. Using this event, you can disable the Row to be copied by checking the selected range type is Rows. Please make use of below code and attached sample,

 

Code snippet:

 

//Trigering the ClipboardCanCopy event

            this.gridControl1.ClipboardCanCopy += new GridCutPasteEventHandler(gridControl1_ClipboardCanCopy);

 

 

//To disable the Row to be copy

        void gridControl1_ClipboardCanCopy(object sender, GridCutPasteEventArgs e)

        {

            //Checking whether selected range type is Row

            if (e.RangeList.ActiveRange.RangeType == GridRangeInfoType.Rows)

            {

                //Disabling the Copy

                e.Result = false;

                e.Handled = true;

            }

        }

 

Note:

As above customization, you can use above code Cut and Paste events.

 

Please let me know if you have any concerns.

 

Regards,

Neelakandan


Attachment: CellGrid_273defc7.zip

vs
Replied On March 11, 2015 09:58 AM

Hi,
Thanks for sample, see my issue in attached sample.

Run the app; select row 1 by clicking on Row header "1". 
Press CtrlC; It shows different properties on can copy event.
Click DisplayClipboard, it shows the whole row ("1 2 3 4 5")
Select the row 1 again by clicking on Row header "1". Click down arrow and then right arrow. now focus is on cell (2,1) with data as "2". 
Press F2, now in edit of that cell.
Select the content by Shift+right Arrow, "2" is selected and highlighted.
Click CtrlC; It shows different properties on can copy event.
CLick DisplayClipboard, it shows the content of the cell ("2")

My problem: how to differentiate these two scenarios? The event properties are same in both cases.
I want to differentiate it and allow copy of cell content on edit and disable copy of the whole row.



Neelakandan Kannan [Syncfusion]
Replied On March 12, 2015 02:58 PM

Hi VS,

Thank you for your update.

It seems that you have not uploaded any sample in your previous update. However we have analyzed your reported scenario. In our previous update, we have provided the solution to restrict the whole row to be copied. The CanCopy event properties will be same in all type of ranges copied. But the type of the selected range can be differentiated by using RangeType property of ActiveRange. Here we have provided the video and sample.

If you have selected Row Range, the RangeType will be Rows. As like Row range, If you have copied data with in cell then RangeType will be Empty. If I misunderstood your query, please provide us sample and screenshot. It would be more help for us to provide better solution as soon as possible.

Code Snippet:

//To disable the Row to be copied

        void gridControl1_ClipboardCanCopy(object sender, GridCutPasteEventArgs e)

        {

            //Checking whether selected range type is Row

            if (e.RangeList.ActiveRange.RangeType == GridRangeInfoType.Rows)

            {               

                //Disabling the Copy

                e.Result = false;

                e.Handled = true;               

            }

            //checking whether copied text is within Cell

            else if (e.RangeList.ActiveRange.RangeType == GridRangeInfoType.Empty)

            {

                MessageBox.Show("It is not Row range...So can be copied");

            }

        }

Sample and Video:

http://www.syncfusion.com/downloads/support/directtrac/118421/Sample_And_Video233374311.zip

Please let me know if you have any concerns.

Regards,

Neelakandan



vs
Replied On March 13, 2015 07:02 AM

Hi,

Thanks for the update.
I have below two properties set and with this, the differentiation is not possible in the sample provided.

this.gridControl1.AllowSelection = ((Syncfusion.Windows.Forms.Grid.GridSelectionFlags)((Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Row | Syncfusion.Windows.Forms.Grid.GridSelectionFlags.AlphaBlend)));
this.gridControl1.ListBoxSelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;

Seems these are required for selection / highlighting the rows.

Regards,
VS

Neelakandan Kannan [Syncfusion]
Replied On March 16, 2015 02:03 PM

Hi VS,

Thank you for your update and cooperation.

The selection range type will always be RowType If ListBoxSelectionMode is used for highlighting the row selection. By default, the RangeList will be returned in the CanCopy event as RowType if ListBoxSelectionMode is enabled. So you can achieve your scenario by only using AllowSelection property. Using that property, you can select any cells, rows, columns. So that RangeList can be differentiated in CanCopy event using AllowSelection property. For more details about ListBoxSelectionMode and AllowSelection mode, please refer to the below UG links,

UG Link:

http://help.syncfusion.com/ug/windows%20forms/Documents/howtomakethegridbeha.htm

http://help.syncfusion.com/ug/windows%20forms/Documents/recordbasedselection.htm

http://help.syncfusion.com/ug/windows%20forms/Documents/selections.htm

Note:

Here we have provided the sample in which we have used only AllowSelection property to select the rows, column, cells. So we request you to use AllowSelection property instead of using ListBoxSelectionMode property to achieve your reported scenario.

Sample:

http://www.syncfusion.com/downloads/support/forum/118421/Modified_Sample-803349302.zip

Please let me know if you have any concerns.

Regards,

Neelakandan


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;