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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to copy complete DataGrid as image to clipboard

Thread ID:

Created:

Updated:

Platform:

Replies:

145892 Jul 12,2019 07:22 AM UTC Jul 15,2019 10:25 AM UTC WPF 1
loading
Tags: GridDataControl
magesh kumar
Asked On July 12, 2019 07:22 AM UTC

Hi,

I have a Syncfusion GridDataControl in my window and a button to copy the contents of the table to clipboard. xaml is given below for reference.

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Button Content="Copy to Clipboard" Height="25" Width="150" Click="CopyDatagrid1" HorizontalAlignment="Right"/>

<syncfusion:LayoutControl SkinPickerVisibility="Collapsed" TraceVisibility="Hidden" 
  syncfusion:LayoutControl.ApplyStyle="True" 
  UserOptionsVisibility="Hidden" Grid.Row="1" VisualStyle="SyncfusionTheme">

<syncfusion:LayoutControl.GridView>
<syncfusion:GridDataControl x:Name="dataGrid1" AllowResizeRows="False"
AutoPopulateColumns="False" AutoPopulateRelations="False" ShowAddNewRow="False" ItemsSource="{Binding DataGrid1Source}" 
VisualStyle="SyncfusionTheme" AllowEdit="False" AllowSort="False">
   
<syncfusion:GridDataControl.VisibleColumns>
<syncfusion:GridDataVisibleColumn MappingName="Column1" HeaderText="Column1" AutoFit="True"/>
<syncfusion:GridDataVisibleColumn MappingName="Column2" HeaderText="Column2" AutoFit="True"/>
<syncfusion:GridDataVisibleColumn MappingName="Column3" HeaderText="Column3" AutoFit="True"/>
<syncfusion:GridDataVisibleColumn MappingName="Column4" HeaderText="Column4" AutoFit="True"/>
</syncfusion:GridDataControl.VisibleColumns>
</syncfusion:GridDataControl>
</syncfusion:LayoutControl.GridView>
</syncfusion:LayoutControl>
</Grid>

I wanted to check if there is an option to copy the entire contents of the table including headers, formatting etc to clipboard and then paste it to image format.
Basically this table which I'm trying to put should be copied as image when the button is pressed.

Kindly advice on how to achieve this.

Thanks,
Magesh

Farjana Parveen Ayubb [Syncfusion]
Replied On July 15, 2019 10:25 AM UTC

Hi Magesh, 
  
Thank you for using Syncfusion controls. 
  
We have analyzed your query, we don’t have a direct support for copy the GridDataControl as an image in clipboard. So we have prepared a workaround for achieve your requirement by convert and copy the visible part of the GridDataControl to an image using RenderTargetBitmap class.   
 
Please refer the following link for sample, 
  
 
Please contact us for further assistance. 
  
Regards, 
Farjana Parveen A 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon