当用户单击行(或列)字段时,我正在寻找一种在剪贴板内复制的方法。示例:当用户单击行(或列)“hello world”并按 ctrl+c 时,剪贴板将填充“hello world”。
提前致谢!
当用户单击行(或列)字段时,我正在寻找一种在剪贴板内复制的方法。示例:当用户单击行(或列)“hello world”并按 ctrl+c 时,剪贴板将填充“hello world”。
提前致谢!
i found a way to do it. On the event of MouseClick on PivotGridControl.
Dim _point As Point = Nothing
Private Sub PivotGridControl1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles PivotGridControl1.KeyDown
If _point.IsEmpty Then
Else
If e.KeyCode = Keys.C AndAlso e.Control Then
Dim field As DevExpress.XtraPivotGrid.PivotFieldValueHitInfo = PivotGridControl1.CalcHitInfo(_point).ValueInfo
Clipboard.SetText(field.Value.ToString())
e.Handled = True
End If
End If
End Sub
Private Sub PivotGridControl1_MouseClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PivotGridControl1.MouseClick
PivotGridControl1.OptionsBehavior.CopyToClipboardWithFieldValues = True
Dim pt As Point = New Point(e.X, e.Y)
If PivotGridControl1.CalcHitInfo(pt).HitTest = DevExpress.XtraPivotGrid.PivotGridHitTest.Value Then
_point = pt
Else
_point = Nothing
End If
End Sub
Thanks everyone for the help
我实现了Ctrl + C
复制的快捷方式,我所做的是KeyDown
为我的 WinForm 控件处理事件:
private static void OnKeyDown(object sender, KeyEventArgs e)
{
// Retrieve sender + view here
if (e.Control && e.KeyCode == Keys.C)
{
Clipboard.SetText(view.GetFocusedDisplayText());
e.Handled = true;
}
}
希望有帮助!