1

当用户单击行(或列)字段时,我正在寻找一种在剪贴板内复制的方法。示例:当用户单击行(或列)“hello world”并按 ctrl+c 时,剪贴板将填充“hello world”。

提前致谢!

4

2 回答 2

1

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

于 2013-06-04T12:39:56.977 回答
1

我实现了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;
    }
}

希望有帮助!

于 2013-06-04T07:41:10.650 回答