2012-06-14 7 views
4

WPF DataGrid을 사용하여 이름 - 값 쌍을 표시하고 있습니다. SelectionUnitFullRow으로 설정되었지만 사용자가 행을 선택하고 누를 때 Ctrl + C 그는 이름과 값의 연결 인 기본 동작 대신 값 텍스트를 실제로 복사하려고합니다. 솔루션을 찾을 때 CopyingRowClipboardContent 이벤트가 발견되었지만 the MSDN page에는 사용 방법에 대한 정보가 없습니다. 또는 PreviewKeyDown 자신을 캡처해야합니까?WPF DataGrid의 Ctrl + C 동작 사용자 정의

답변

2

을 위해 할 수 찾고있는 무슨이다.

디 컴파일 소스 코드를

public class DataGridRowClipboardEventArgs 
{ 
    /// <summary> 
    /// This list should be used to modify, add or remove a cell 
    /// content before it gets stored into the clipboard. 
    /// </summary> 
    public List<DataGridClipboardCellContent> ClipboardRowContent 
    { 
     ... 

당신이 두 개의 열이 있고 첫 번째를 원한다면 예를 들어,이 같은 두 번째 항목을 제거 할 수 있습니다

private void grid_CopyingRowClipboardContent(
    object sender, DataGridRowClipboardEventArgs e) 
{ 
    e.ClipboardRowContent.RemoveAt(1); 
} 
0

은 아마 당신이 DataGridRowClipboardEventArgs를 사용하여 CopyingRowClipboardContent 이벤트 처리기에서 복사 된 데이터를 수정

ClipboardCopyMode = DataGridClipboardCopyMode.ExcludeHeader;

+0

아니, 제외의를 열 머리글 및 원하는 행에서 특정 셀을 제외 할 수 있습니다. –

관련 문제