I am facing an issue while dragging a row from source RadGridView which is in separate window (different instance of same application) and dropping it in target RadGridView which is in separate window (different instnace of the same application). I have implemented like following but I am getting an exception which is following. But if I drag text from textbox and drop into RadGridView instead of using GridRow as source it works fine. Please help is to resolve this issue.
"Error HRESULT E_FAIL has been returned from a call to a COM component."
App.xaml file contents are following:
=============================
<Application x:Class="DragAndDropWPFApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns:telerik=http://schemas.telerik.com/2008/xaml/presentation
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="telerik:GridViewRow">
<Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True"></Setter>
<Setter Property="telerik:RadDragAndDropManager.AutoDrag" Value="True"></Setter>
</Style>
</Application.Resources>
</Application>
====================================
I have two RadGridViews in the xaml windows which names are following:
1. rgvSource
2. rgvTarget
Code in the code behind file is following for DragOver Event.
private void rgvSource_DragOver(object sender, DragEventArgs e)
{
RadGridView grid = (RadGridView)sender;
GridViewRow row = (GridViewRow)this.rgvSource.ItemContainerGenerator.ContainerFromItem(this.rgvSource.SelectedItem);
User user = row.Item as User;
string data = user.Id.ToString() + "," + user.UserName + "," + user.LastLoginDate.ToShortDateString();
DragDrop.DoDragDrop(rgvSource, data , DragDropEffects.Copy);
}
Dropped Grid event is following
================================
private void rgvTarget_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effects = DragDropEffects.Copy;
else
e.Effects = DragDropEffects.None;
}
private void rgvTarget_Drop(object sender, DragEventArgs e)
{
MessageBox.Show(e.Data.GetData(DataFormats.Text).ToString());
}
=============================================================
so how to resolve Com expection?
Hope someone will help me out to resolve this issue. Its urgent.
Thanks
Laxman