I have a DataGrid
. But I want to get focused cell value in CopyingRowClipboardContent
event. But e.ClipboardRowContent
returns me all selected cells values because of the SelectionUnit
. And i must not change selection unit of datagrid. For solving the problem i need to get focused cell column number. Then I will remove all column values from clipboarcContent
.
How can i get focused cell in CopyingRowClipboardContent
event?
Improved version of Farhad's answer
private void DataGrid_CopyingRowClipboardContent(object sender, DataGridRowClipboardEventArgs e)
{
var currentCell = e.ClipboardRowContent[ dataGrid.CurrentCell.Column.DisplayIndex];
e.ClipboardRowContent.Clear();
e.ClipboardRowContent.Add( currentCell );
}
You can also use the following code in order control clipboard content.
Clipboard.SetText("some value");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With