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

Copy with Multi Paste

I am using a virtual grid. I would like the have the following behavior. 1. User types in "12" into a cell. User clicks Control+C i copy the current cell. 2. User highlights a list of continuous cells. 3. User type in Control+V and all cells that are highlighted should display "12". In the normal copy and paste from one cell to another, i get the regular CurrentCellValidating and SaveCellInfo events for the "pasted" cell. How would i do this if there were multiple "pasted" cells. It seems like i would either need the regular callback for each of the pasted cells or a callback that includes a ranged of pasted cell. Any thoughts ??? thks, ak

6 Replies

AD Administrator Syncfusion Team June 8, 2006 04:15 AM UTC

Hi Adam , There is no built-in support for this. Try this code to copy/Paste the highlighted cells. Here is a code snippet. private void Model_ClipboardPaste(object sender, GridCutPasteEventArgs e) { DataObject obj = Clipboard.GetDataObject() as DataObject; string data = obj.GetData(typeof(string)).ToString() ; GridRangeInfo info = this.gridControl1.Model.SelectedRanges.ActiveRange; int CopiedRangeTopBottomDiff = e.RangeList.ActiveRange.Top - e.RangeList.ActiveRange.Bottom; int PatingRangeTopBottomDiff = info.Top - info.Bottom; int CopiedRangeLeftRightDiff = e.RangeList.ActiveRange.Right - e.RangeList.ActiveRange.Left; int PatingRangeLeftRightDiff = info.Right - info.Left; int ProcessOnCopyTopBottom =( PatingRangeTopBottomDiff > 0 ? PatingRangeTopBottomDiff : -1 * PatingRangeTopBottomDiff ) - (CopiedRangeTopBottomDiff > 0 ? CopiedRangeTopBottomDiff : -1 * CopiedRangeTopBottomDiff ); int ProcessOnCopyLeftRight =( PatingRangeLeftRightDiff > 0 ? PatingRangeLeftRightDiff : -1 * PatingRangeLeftRightDiff )- (CopiedRangeLeftRightDiff > 0 ? CopiedRangeLeftRightDiff : -1 * CopiedRangeLeftRightDiff ); if( ProcessOnCopyTopBottom > 0 ) { string addRangeData = data; for( int i = 0 ; i < ProcessOnCopyTopBottom ;i++) { data += addRangeData; } } Clipboard.SetDataObject(data); } Here is a sample. http://www.syncfusion.com/Support/user/uploads/VirtualGrid.zip Please let me know if this helps. Best Regards, Haneef


AK Adam K. June 8, 2006 11:43 AM UTC

this doesn''t seem to work, either in my project or your sample. I loaded your sample, hit control+C on one of the cells to copy it. I then highlighted a few cells and clicked control+V to paste and it only pasted in the last cell at the bottom . my request was to mimic Excel and have it paste into all of the cells that were highlighted. please let me know your thoughts. thks, ak >Hi Adam , > >There is no built-in support for this. Try this code to copy/Paste the highlighted cells. Here is a code snippet. > >private void Model_ClipboardPaste(object sender, GridCutPasteEventArgs e) >{ > DataObject obj = Clipboard.GetDataObject() as DataObject; > string data = obj.GetData(typeof(string)).ToString() ; > > GridRangeInfo info = this.gridControl1.Model.SelectedRanges.ActiveRange; > > int CopiedRangeTopBottomDiff = e.RangeList.ActiveRange.Top - e.RangeList.ActiveRange.Bottom; > int PatingRangeTopBottomDiff = info.Top - info.Bottom; > > int CopiedRangeLeftRightDiff = e.RangeList.ActiveRange.Right - e.RangeList.ActiveRange.Left; > int PatingRangeLeftRightDiff = info.Right - info.Left; > > int ProcessOnCopyTopBottom =( PatingRangeTopBottomDiff > 0 ? PatingRangeTopBottomDiff : -1 * PatingRangeTopBottomDiff ) - (CopiedRangeTopBottomDiff > 0 ? CopiedRangeTopBottomDiff : -1 * CopiedRangeTopBottomDiff ); > int ProcessOnCopyLeftRight =( PatingRangeLeftRightDiff > 0 ? PatingRangeLeftRightDiff : -1 * PatingRangeLeftRightDiff )- (CopiedRangeLeftRightDiff > 0 ? CopiedRangeLeftRightDiff : -1 * CopiedRangeLeftRightDiff ); > > if( ProcessOnCopyTopBottom > 0 ) > { > string addRangeData = data; > for( int i = 0 ; i < ProcessOnCopyTopBottom ;i++) > { > data += addRangeData; > } > } > Clipboard.SetDataObject(data); >} > >Here is a sample. >http://www.syncfusion.com/Support/user/uploads/VirtualGrid.zip > >Please let me know if this helps. >Best Regards, >Haneef


AK Adam K. June 8, 2006 11:44 AM UTC

even stranger is that i dont see any: Model_ClipboardPaste code in your example. Did you give me an incorrect link? thks, ak >this doesn''t seem to work, either in my project or your sample. > >I loaded your sample, hit control+C on one of the cells to copy it. I then highlighted a few cells and clicked control+V to paste and it only pasted in the last cell at the bottom . my request was to mimic Excel and have it paste into all of the cells that were highlighted. > >please let me know your thoughts. > >thks, >ak > > >>Hi Adam , >> >>There is no built-in support for this. Try this code to copy/Paste the highlighted cells. Here is a code snippet. >> >>private void Model_ClipboardPaste(object sender, GridCutPasteEventArgs e) >>{ >> DataObject obj = Clipboard.GetDataObject() as DataObject; >> string data = obj.GetData(typeof(string)).ToString() ; >> >> GridRangeInfo info = this.gridControl1.Model.SelectedRanges.ActiveRange; >> >> int CopiedRangeTopBottomDiff = e.RangeList.ActiveRange.Top - e.RangeList.ActiveRange.Bottom; >> int PatingRangeTopBottomDiff = info.Top - info.Bottom; >> >> int CopiedRangeLeftRightDiff = e.RangeList.ActiveRange.Right - e.RangeList.ActiveRange.Left; >> int PatingRangeLeftRightDiff = info.Right - info.Left; >> >> int ProcessOnCopyTopBottom =( PatingRangeTopBottomDiff > 0 ? PatingRangeTopBottomDiff : -1 * PatingRangeTopBottomDiff ) - (CopiedRangeTopBottomDiff > 0 ? CopiedRangeTopBottomDiff : -1 * CopiedRangeTopBottomDiff ); >> int ProcessOnCopyLeftRight =( PatingRangeLeftRightDiff > 0 ? PatingRangeLeftRightDiff : -1 * PatingRangeLeftRightDiff )- (CopiedRangeLeftRightDiff > 0 ? CopiedRangeLeftRightDiff : -1 * CopiedRangeLeftRightDiff ); >> >> if( ProcessOnCopyTopBottom > 0 ) >> { >> string addRangeData = data; >> for( int i = 0 ; i < ProcessOnCopyTopBottom ;i++) >> { >> data += addRangeData; >> } >> } >> Clipboard.SetDataObject(data); >>} >> >>Here is a sample. >>http://www.syncfusion.com/Support/user/uploads/VirtualGrid.zip >> >>Please let me know if this helps. >>Best Regards, >>Haneef


AK Adam K. June 8, 2006 11:48 AM UTC

i stepped through your code and your code seems to be concatenating values here. I simply want to take 1 cell and paste that one value into multiple cells at once with one Control+V command. thks, ak >even stranger is that i dont see any: > >Model_ClipboardPaste > >code in your example. Did you give me an incorrect link? > >thks, >ak > >>this doesn''t seem to work, either in my project or your sample. >> >>I loaded your sample, hit control+C on one of the cells to copy it. I then highlighted a few cells and clicked control+V to paste and it only pasted in the last cell at the bottom . my request was to mimic Excel and have it paste into all of the cells that were highlighted. >> >>please let me know your thoughts. >> >>thks, >>ak >> >> >>>Hi Adam , >>> >>>There is no built-in support for this. Try this code to copy/Paste the highlighted cells. Here is a code snippet. >>> >>>private void Model_ClipboardPaste(object sender, GridCutPasteEventArgs e) >>>{ >>> DataObject obj = Clipboard.GetDataObject() as DataObject; >>> string data = obj.GetData(typeof(string)).ToString() ; >>> >>> GridRangeInfo info = this.gridControl1.Model.SelectedRanges.ActiveRange; >>> >>> int CopiedRangeTopBottomDiff = e.RangeList.ActiveRange.Top - e.RangeList.ActiveRange.Bottom; >>> int PatingRangeTopBottomDiff = info.Top - info.Bottom; >>> >>> int CopiedRangeLeftRightDiff = e.RangeList.ActiveRange.Right - e.RangeList.ActiveRange.Left; >>> int PatingRangeLeftRightDiff = info.Right - info.Left; >>> >>> int ProcessOnCopyTopBottom =( PatingRangeTopBottomDiff > 0 ? PatingRangeTopBottomDiff : -1 * PatingRangeTopBottomDiff ) - (CopiedRangeTopBottomDiff > 0 ? CopiedRangeTopBottomDiff : -1 * CopiedRangeTopBottomDiff ); >>> int ProcessOnCopyLeftRight =( PatingRangeLeftRightDiff > 0 ? PatingRangeLeftRightDiff : -1 * PatingRangeLeftRightDiff )- (CopiedRangeLeftRightDiff > 0 ? CopiedRangeLeftRightDiff : -1 * CopiedRangeLeftRightDiff ); >>> >>> if( ProcessOnCopyTopBottom > 0 ) >>> { >>> string addRangeData = data; >>> for( int i = 0 ; i < ProcessOnCopyTopBottom ;i++) >>> { >>> data += addRangeData; >>> } >>> } >>> Clipboard.SetDataObject(data); >>>} >>> >>>Here is a sample. >>>http://www.syncfusion.com/Support/user/uploads/VirtualGrid.zip >>> >>>Please let me know if this helps. >>>Best Regards, >>>Haneef


AD Administrator Syncfusion Team June 8, 2006 12:34 PM UTC

Hi Adam, Sorry for the inconvenience caused. Please find the sample from below link. http://www.syncfusion.com/Support/user/uploads/VirtualGrid_adb36918.zip Let me know if this helps. Best Regards, Haneef


AD Administrator Syncfusion Team June 9, 2006 06:02 PM UTC

Adam, We wanted to do the same thing you are trying and used this code that works flawlessly. Give this a look http://syncfusion.com/Support/forums/message.aspx?MessageID=5796 Phil

Loader.
Live Chat Icon For mobile
Up arrow icon