|
this.gridGroupingControl1.TableModel.ClipboardCanCopy += TableModel_ClipboardCanCopy;
private void TableModel_ClipboardCanCopy(object sender, GridCutPasteEventArgs e)
{
this.CopySelectedRecords(false);
e.Result = false;
e.Handled = true;
}
private void CopySelectedRecords(bool cut)
{
string s = "";
//Copying the selected records.
if (this.gridGroupingControl1.Table.SelectedRecords.Count > 0)
{
foreach (SelectedRecord selRec in this.gridGroupingControl1.Table.SelectedRecords)
{
for (int i = 0; i < this.gridGroupingControl1.TableDescriptor.VisibleColumns.Count; i++)
{
GridVisibleColumnDescriptor vcd = this.gridGroupingControl1.TableDescriptor.VisibleColumns[i];
if (vcd.Name != "Country") // Here, Country column value has avoided to copy the data in clipboard.
{
if (i != 0)
{
s += "\t";
}
s += selRec.Record.GetValue(vcd.Name).ToString();
if (cut)
{
selRec.Record.SetValue(vcd.Name, "");
}
}
}
s += Environment.NewLine;
}
}
Clipboard.SetDataObject(new DataObject(s), true);
} |