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

Clipborad copy/pase in GridControl

Hi, While pasting the clip board the values are also pasted in the first column for which I defined the celltype as "Static". But I dont want to paste the values in first column. Pls let me know how to do ASAP. Thanks Ravi

5 Replies

AD Administrator Syncfusion Team July 12, 2006 10:56 PM UTC

Hi Ravi, Please try setting the ReadOnly property for the static cells to true; this will avoid pasting of the values into static cells. Best regards, Madhan


RA Ravichandran July 13, 2006 08:26 AM UTC

Hi Madhan How to set that static cell to Readonly. BaseStylesMap["Row Header"].StyleInfo.CellType = "Static"; BaseStylesMap["Row Header"].StyleInfo.ReadOnly = true; Is this correct? Pls let me know Thanks Ravi >Hi Ravi, > >Please try setting the ReadOnly property for the static cells to true; this will avoid pasting of the values into static cells. > >Best regards, >Madhan >


AD Administrator Syncfusion Team July 13, 2006 10:13 AM UTC

Hi Ravi, By default you cant able to paste in the rowheaders. You can set ReadOnly to true for any specfic column through the code below, this.gridControl1.ColStyles[1].ReadOnly = true; If you have various cells in the grid declared as static, then you may query for the static cells in the QueryCellInfo event hander and set the ReadOnly property to true accordingly. if(e.Style.CellType == "Static") e.Style.ReadOnly = true; Let me know if you have any other questions. Thanks, Rajagopal


RA Ravichandran July 13, 2006 11:03 AM UTC

Hi Rajagopal, It didnt work..Pls find the code snippet below for event ClipboardPaste and also attached the screen shot pls let me know the solution protected void grid_ClipboardPaste(object sender, Syncfusion.Windows.Forms.Grid.GridCutPasteEventArgs e) { CommandStack.BeginTrans(@"Paste"); // Check to see if this is a paste of new securities if ( CurrentCell.ColIndex == (int)SecurityPricingDocument.SecurityPricingColumn.Identifier ) { DataObject data = Clipboard.GetDataObject() as DataObject; if ( data.GetDataPresent( DataFormats.Text ) ) { // Determine the number of rows to be pasted string s = data.GetData( DataFormats.Text ).ToString(); string[] rows = s.Split(new char[] { '''' } ); int numRows = rows.GetLength(0); // Ignore blank line after the last line feed marker if (( numRows > 0) && (rows[(numRows - 1)].Length == 0)) numRows -= 1; // If we have valid row(s) to paste, check to see if we need to first create new empty rows int lastRowIndex = CurrentCell.RowIndex + numRows; if (lastRowIndex >= RowCount) Document.AddRows(numRows); // // For each pasted row, set the Extract checkbox int startRowIndex = CurrentCell.RowIndex; // for ( int rowIndex = startRowIndex; rowIndex < lastRowIndex; rowIndex++ ) // this[rowIndex, (int)SecurityPricingDocument.SecurityPricingColumn.].CellValue = true; } } OnModifiedChanged(new EventArgs()); CommandStack.CommitTrans(); } Thanks Ravi >Hi Ravi, > >By default you cant able to paste in the rowheaders. You can set ReadOnly to true for any specfic column through the code below, > >this.gridControl1.ColStyles[1].ReadOnly = true; > >If you have various cells in the grid declared as static, then you may query for the static cells in the QueryCellInfo event hander and set the ReadOnly property to true accordingly. > >if(e.Style.CellType == "Static") > e.Style.ReadOnly = true; > >Let me know if you have any other questions. >Thanks, >Rajagopal

image7.zip


AD Administrator Syncfusion Team July 13, 2006 02:34 PM UTC

Hi Ravi, When you are copying and pasting data from the clipboard, the default behavior is to copy and paste the style information with the text. In such case, the readonly cells will also get pasted. To avoid this you can turn off the default support for copying styles, through the below code. this.gridControl1.CutPaste.ClipboardFlags &= ~GridDragDropFlags.Styles; Also, please refer to forum thread below http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=22468 Let me know if this helps. Thanks, Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon