[英]Copy text of single cell to clipboard
My CurrentCellValue is always null. 我的CurrentCellValue始终为null。
I want to mark a row but also if I choose to copy ( Ctrl + C ) a cell I want that value to be copied, now I get the whole row. 我想标记一行,但是如果我选择复制( Ctrl + C )一个我想要复制该值的单元格,那么现在我得到了整行。
<dxg:GridControl
Name="GridControl"
ColumnsSource="{Binding Columns}"
ItemsSource="{Binding Orders}"
ColumnGeneratorTemplate="{StaticResource ColumnTemplate}"
AutoGenerateColumns="None"
ColumnGeneratorStyle="{StaticResource CommonColumnStyle}"
SelectedItems="{Binding SelectedOrders}"
SelectionMode="Row"
CustomSummary="GridControl_OnCustomSum"
SelectionChanged="GridControl_OnSelectionChanged"
CopyingToClipboard="GridControl_OnCopyingToClipboard">
private void GridControl_OnCopyingToClipboard(object sender, CopyingToClipboardEventArgs e)
{
Clipboard.Clear();
Clipboard.SetText(GetRowData());
e.Handled = true;
}
private string GetRowData()
{
return GridControl.CurrentCellValue.ToString();
}
SOLUTION: 解:
<dxg:TableView Name="GridTableView" NavigationStyle="Cell" />
Now I have a value in CurrentCellValue 现在我在CurrentCellValue中有一个值
You can add "SelectedItem" Binding to your GridControl, and in "GridControl_OnCopyingToClipboard" try to find inside the selectedItem the relevant text that you want to copy. 您可以将“ SelectedItem”绑定添加到GridControl,然后在“ GridControl_OnCopyingToClipboard”中尝试在selectedItem内找到要复制的相关文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.