C# DevExpress TableView单元格的焦点不在CopyingToClipboard事件上
我正在尝试修复此自定义的DevExpress表视图。正如您所猜测的,下面的方法处理CopyingToClipboard。当我投射FocusedElement时,它是一个BaseEdit,但不是我准确选择的那个。它的显示文本是不同的 我已经更改了单元格的背景色,以确保它具有焦点,并且是选中的单元格。这不是问题所在。你能分享一下你的智慧吗C# DevExpress TableView单元格的焦点不在CopyingToClipboard事件上,c#,wpf,devexpress,devexpress-wpf,C#,Wpf,Devexpress,Devexpress Wpf,我正在尝试修复此自定义的DevExpress表视图。正如您所猜测的,下面的方法处理CopyingToClipboard。当我投射FocusedElement时,它是一个BaseEdit,但不是我准确选择的那个。它的显示文本是不同的 我已经更改了单元格的背景色,以确保它具有焦点,并且是选中的单元格。这不是问题所在。你能分享一下你的智慧吗 private void CustomizedTableView_CopyingToClipboard(object sender, CopyingToClipb
private void CustomizedTableView_CopyingToClipboard(object sender, CopyingToClipboardEventArgs e)
{
TableView view = sender as TableView;
if (view == null || view.Grid == null)
{
return;
}
BaseEdit edit = System.Windows.Input.Keyboard.FocusedElement as BaseEdit;
edit.Background = Brushes.Red;
VantageUtilities.SafeCopyToClipboard(DataFormats.Text, edit.DisplayText);
e.Handled = true;
}
您可以使用属性获取聚焦编辑器,也可以使用属性获取聚焦值。下面是一个例子:
private void CustomizedTableView_CopyingToClipboard(object sender, CopyingToClipboardEventArgs e)
{
TableView view = sender as TableView;
if (view == null || view.Grid == null)
return;
string text = null;
if (view.ActiveEditor != null)
text = view.ActiveEditor.DisplayText;
else
{
object value = view.Grid.CurrentCellValue;
if (value != null)
text = value.ToString();
}
if (text == null)
return;
VantageUtilities.SafeCopyToClipboard(DataFormats.Text, text);
e.Handled = true;
}
PS:DataControlBase中有一些CopySomethingToClipboard
方法:方法、方法、方法、方法和方法。你可以看看