问题内容: I want to copy a cell from a datagridview with the columnheader. (Not the row header). I tried this, but i get an exception: if (dataGridView1.GetCellCount(DataGridViewElementStates.Selected) > 0) { foreach (DataGridViewColumn c in dataGridView1.Columns) { c.SortMode = DataGridViewColumnSortMode.NotSortable; } dataGridView1.SelectionMode = DataGridviewSelectionMode.ColumnHeaderSelect; //only the column headers will be copied dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText; //.EnableWithAutoHeaderText; //