如果我在DataGridViewTextBoxCell
中编辑DataGridView
并按向右箭头移动到字符串的末尾,当我到达字符串的末尾时,光标将离开编辑模式DataGridViewTextBoxCell
并选择旁边的DataGridViewTextBoxCell
。
这是默认行为吗?
有没有办法将插入符号/光标保留在当前正在编辑的DataGridViewTextBoxCell
内?
答案 0 :(得分:0)
private bool dont_jump;
private int col_index;
private int row_index;
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
dont_jump = true;
col_index = e.ColumnIndex;
row_index = e.RowIndex;
}
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dont_jump)
{
dont_jump= false;
dataGridView1.CurrentCell = dataGridView1[col_index, row_index];
}
}
也许这对你有用