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.
Syncfusion Feedback

Copy and Paste of hidden columns

Thread ID:

Created:

Updated:

Platform:

Replies:

7382 Sep 23,2003 05:39 PM UTC Oct 20,2003 02:37 PM UTC Windows Forms 3
loading
Tags: GridControl
Jorge A. Hernandez
Asked On September 23, 2003 05:39 PM UTC

There is an strange situation with the copy and paste of columns. If I have a grid with hidden columns and I mark the visible cells and do copy and paste in Excel I am going to see the values for all the columns including the hidden too. I would like not to include the hidden columns in the copy and paste functionality of the grid. Is there any way to achieve that? Thanks in advance

Administrator [Syncfusion]
Replied On September 23, 2003 08:50 PM UTC

You have to handle the Model.ClipboardCopy event and copy the cells manually to the clipboard and skip hidden cells. Once you are done copying text to the clipboard be sure to set e.Handled = true. I am enclosing code from the grids CopyTextToBuffer method. You could adjust this code to your needs. public bool CopyTextToBuffer(out string buffer, GridRangeInfoList rangeList, out int nRowsDone, out int nColsDone) { // store rows/columns indizes to process in an array GridRangeInfoList rowRanges = rangeList.GetRowRanges(GridRangeInfoType.Cells|GridRangeInfoType.Rows); GridRangeInfoList colRanges = rangeList.GetColRanges(GridRangeInfoType.Cells|GridRangeInfoType.Cols); // determine no of rows/cols to process int nRows = 0; foreach (GridRangeInfo range in rowRanges) nRows += range.Height; int nCols = 0; foreach (GridRangeInfo range in colRanges) nCols += range.Width; int dwSize = nRows*nCols; nRowsDone = 0; nColsDone = 0; // status message, let the user abort the operation using (OperationFeedback op = new OperationFeedback(Model)) { op.Description = SR.GetString("GRID_IDM_COPYTEXT"); op.AllowCancel = true; bool canceled = false; bool bAnyChar = false; string sTabDelim = "\t"; if (m_sExportTabDelim != null && m_sExportTabDelim.Length > 0) sTabDelim = m_sExportTabDelim; #if DEBUG if (sTabDelim.Length > 1) { Trace.WriteLineIf(Switches.DataExchange.TraceWarning, "Warning: the length of m_sExportTabDelim in CopyTextToFile is more than one character!"); Trace.WriteLineIf(Switches.DataExchange.TraceWarning, String.Format("Columns will be separated with the following string: {0}", m_sExportTabDelim)); } #endif StringBuilder sb = new StringBuilder(); try { // fill pOldCellsArray row by row for (int rowindex = 0; !canceled && rowindex < rowRanges.Count; rowindex++) { for (int nRow = rowRanges[rowindex].Top; nRow <= rowRanges[rowindex].Bottom; nRow++) { if (nRowsDone > 0) sb.Append(Environment.NewLine); bool firstCol; firstCol = true; nColsDone = 0; for (int colindex = 0; !canceled && colindex < colRanges.Count; colindex++) { for (int nCol = colRanges[colindex].Left; nCol <= colRanges[colindex].Right; nCol++) { // Store styles in array, but allow user to abort int dwIndex = nRowsDone*nCols+nColsDone; if (!firstCol) sb.Append(sTabDelim); // Get text from control (and give control the chance // to convert value into unformatted text or vice versa). string sText = GetCopyTextRowCol(nRow, nCol); sText = new StringBuilder(sText) .Replace(Environment.NewLine, " ") .Replace("\r", " ") .Replace("\n", " ") .ToString() .Trim(); sb.Append(sText); bAnyChar |= sText.Length > 0; firstCol = false; // check, if user pressed ESC to cancel op.PercentComplete = (int) (dwIndex * 100 / dwSize); if (op.ShouldCancel) throw new GridUserCanceledException(); nColsDone++; } } nRowsDone++; } } } catch(GridUserCanceledException ex) { TraceUtil.TraceExceptionCatched(ex); if (!ExceptionManager.RaiseExceptionCatched(this, ex)) throw ex; canceled = true; } if (nRowsDone > 1 || nColsDone > 1) sb.Append(Environment.NewLine); buffer = sb.ToString(); return !canceled && bAnyChar; } } Stefan

Terry Foster
Replied On October 20, 2003 01:47 PM UTC

I am also in need of this functionality (including pasting a range over only visible rows/columns). Have you considered making this an option? Terry

Administrator [Syncfusion]
Replied On October 20, 2003 02:37 PM UTC

We'll be adding an option but it is not a priority right now. In 2.1 or later we will look again at current Clipboard behavior and make it more flexible and also provide more options. For now, you would need to implement your own approach. Thanks, Stefan

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.

Warning Icon 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.Close Icon

;