private void ListView_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.C) { if (ListView.Items.Count > 0) { int col = ListView.Columns.Count; StringBuilder sb = new StringBuilder(); foreach (ListViewItem item in ListView.SelectedItems) { if (item.Text != "") { for (int i = 0; i < col; i++) { sb.Append(item.SubItems[i].Text); if (i == col - 1) sb.Append("\r\n"); } } } Clipboard.SetDataObject(sb.ToString()); } } }
private void ListView_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.C) { if (ListView.Items.Count > 0) { int col = ListView.Columns.Count; StringBuilder sb = new StringBuilder(); foreach (ListViewItem item in ListView.SelectedItems) { if (item.Text != "") { for (int i = 0; i < col; i++) { sb.Append(item.SubItems[i].Text); if (i == col - 1) sb.Append("\r\n"); } } } Clipboard.SetDataObject(sb.ToString()); } } }