WPF DataGrid復制單元格問題


當復制出現 以下錯誤時:System.Runtime.InteropServices.COMException (0x800401D0),這是在WPF剪貼板程序錯誤。


解決方法:則在需要在App.xaml.cs添加以下代碼
    private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
        
            var comException = e.Exception as System.Runtime.InteropServices.COMException;
            if (comException != null && comException.ErrorCode == -2147221040)
            {
                e.Handled = true;
            }
     
        }
一般是DataGridTextColumn是可以直接復制,如果是DataGridTemplateColumn,則需要在添加   ClipboardContentBinding="{Binding 綁定的屬性}"
DataGridTemplateColumn中.

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM