Hi to all,
I trying to copy from one gridview that has 4 columns and paste another gridview that has 3 columns.
Now, in RadGridViewPasting of destination GridView I wrote this code, those gridviews are into Windows dialog that called from main Windows with ShowDialog mode. But this code generate an error.
If I compare ContainsData in incoming and ContainsData in outcoming are formally correct.
What's up?
01.
private
void
MappingRadGridViewPasting(
object
sender, GridViewClipboardEventArgs e)
02.
{
03.
try
04.
{
05.
if
(Clipboard.ContainsData(DataFormats.Text))
06.
{
07.
string
data = Clipboard.GetData(DataFormats.Text).ToString();
08.
if
(data !=
string
.Empty)
09.
{
10.
var items = data.Split(
'\n'
);
11.
12.
StringBuilder sb =
new
StringBuilder();
13.
14.
for
(
int
i = 0; i < items.Length; i++)
15.
{
16.
var fields = items[i].Split(
'\t'
);
17.
18.
int
type = Convert.ToInt32(fields[0]);
19.
int
id = Convert.ToInt32(fields[1]);
20.
string
name = fields[2];
21.
22.
if
(i == items.Length - 1)
23.
sb.AppendFormat(
"{0}\t{1}\t\t{2}"
, type, id, name);
24.
else
25.
sb.AppendFormat(
"{0}\t{1}\t\t{2}\r\n"
, type, id, name);
26.
}
27.
28.
string
output = sb.ToString();
29.
30.
Clipboard.SetData(DataFormats.Text, output);
31.
}
32.
}
33.
34.
}
35.
catch
(Exception ex)
36.
{
37.
ExceptionHelper.ShowException(
"MappingRadGridViewPasting"
, ex);
38.
}
39.
}