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.

Copy with Multi Paste

Thread ID:

Created:

Updated:

Platform:

Replies:

44965 Jun 7,2006 05:42 PM Jun 9,2006 02:02 PM Windows Forms 6
loading
Tags: GridControl
Adam K.
Asked On June 7, 2006 05:42 PM

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

Administrator [Syncfusion]
Replied On June 8, 2006 12:15 AM

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

Adam K.
Replied On June 8, 2006 07:43 AM

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

Adam K.
Replied On June 8, 2006 07:44 AM

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

Adam K.
Replied On June 8, 2006 07:48 AM

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

Administrator [Syncfusion]
Replied On June 8, 2006 08:34 AM

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

Administrator [Syncfusion]
Replied On June 9, 2006 02:02 PM

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

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.

;