Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Copying to Clipboard

Sort Posts: Previous Next
  •  08-07-2008, 1:04 PM Post no. 13947

    Copying to Clipboard

    I use the following code to copy the selected row content to the clipboard:

                          if (grid != null)
                {
                    if (grid.SelectedItems.Count > 0)
                    {
                        StringBuilder strGridStrings = new StringBuilder();
                      
                        for( int i = 0;  i <= grid.SelectedItems.Count - 1; i++ )
                        {                       
                            Row row = (Row)grid.GetContainerFromItem(grid.SelectedItems[ i ]);

                            if (row != null)
                            {
                                foreach (Cell gridCell in row.Cells)
                                {
                                    if (gridCell != null && gridCell.HasContent)
                                    {
                                        strGridStrings.Append(gridCell.Content.ToString()).Append("\t");
                                    }                            
                                }
                            }

                            strGridStrings.Append("\r\n");                        
                        }

                        
                        string strClipboardString = strGridStrings.ToString().TrimEnd("\t\r\n".ToCharArray());
                       
                        Clipboard.SetText(strClipboardString);
                    }
                }

     

    This works fine, except if i cahnge the sort order of the rows or columns then the content that gets copied into the clipboard doesn't reflect the user specified order, what's the best way to deal with this?

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.