我不想复制datagridview
冻结列中的值。只有我能够复制Unfrozen列。如何解决?
答案 0 :(得分:1)
我不认为DGV
或其Cells
中存在相关属性。但在EditingControl
中有:
// subscribe to the event that goes with entering edit mode:
private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
// get a reference to the currently showing edit control:
DataGridViewTextBoxEditingControl tb = DataGridViewTextBoxEditingControl) e.Control;
// disallow the standard actions
tb.ShortcutsEnabled =
!dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].Frozen;
}
我们还需要在不进入编辑模式的情况下禁止键盘复制:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].Frozen)
e.Handled = true;
}