Copy/Paste

6 posts, 0 answers
  1. CarlosLima
    CarlosLima avatar
    47 posts
    Member since:
    May 2010

    Posted 29 Nov 2010 Link to this post

    I know that it possible to copy/paste the grid's content but when I have a custom header, let's say with a textblock on it, how do I set the copy/paste to make sure that when the cells and the header are copied to the clipboard, the header has what I want it to have (and not the textblock class type text...)

    Thanks.
    Carlos
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 01 Dec 2010 Link to this post

    Hello carlos,

    To overcome the problem you need to subscribe to the Copying event of the gridview and set the Header of the particular column to a string:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
        <telerik:GridViewDataColumn.Header>
            <StackPanel>
                <TextBlock Text="my custom header" />
                <TextBlock Text="another line" />
            </StackPanel>
        </telerik:GridViewDataColumn.Header>
    </telerik:GridViewDataColumn>

    private void clubsGrid_Copying(object sender, GridViewClipboardEventArgs e)
    {
        var column = this.clubsGrid.Columns["Name"];
        if (column.Header is StackPanel)
        {
            var sp = column.Header as StackPanel;
            var headerText = string.Empty;
     
            foreach (var tb in sp.ChildrenOfType<TextBlock>())
            {
                headerText += tb.Text + " ";
            }
     
            column.Header = headerText;
        }          
    }

    Now, the clipboard will have the correct header.
    Finally, you need to restore the original look of the Header in the Copied event.


    Sincerely yours,
    Veselin Vasilev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. David Ocasio
    David Ocasio avatar
    147 posts
    Member since:
    Nov 2009

    Posted 09 Jan 2012 Link to this post

    is there any update on this particular issue

    it is not very practical to rewrite the header just for the sake of the clipboard function
    and then try and restore it to its original values afterwards.

    i would prefer it to show in the CopyingCellClipboardContent event or
    act similiar to the elementexporting event
    so i can adjust it before it is copied to the clipboard

    is there something i am missing
    another event.

    Any help will be appreciated

    thanks
    dco
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 10 Jan 2012 Link to this post

    Hello dco,

     I understand your point, but we do not have any update on this functionality.

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Deborah
    Deborah avatar
    31 posts
    Member since:
    Jun 2011

    Posted 12 Dec 2012 Link to this post

    Hi,
    still no updates on this argument?
    Thanks.
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 12 Dec 2012 Link to this post

    Hi,

    I am afraid that such a functionality is still not supported.

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner