gpt4 book ai didi

c# - 将光标保持在数据 GridView 的特定列内

转载 作者:行者123 更新时间:2023-12-02 21:28:15 25 4
gpt4 key购买 nike

我正在开发 Windows 窗体应用程序..

我有一个像这样的数据 GridView :

enter code here

这里我在驱动程序 ID 列中我必须输入驱动程序 ID。输入驱动器 ID 后,我将按 Enter 按钮。同时,光标通过释放按钮移动到下一列,但我不想自动将光标移动到那里,我想始终将光标保留在驱动程序 id 列中。

我怎样才能实现这一目标?

最佳答案

保持原样和用户 datagridview 单元格结束编辑事件怎么样?

    private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{

if (dataGridView1.Columns[e.ColumnIndex].Name=="driverid")
{

dataGridView1.CurrentCell = dataGridView1.Rows[(e.RowIndex+1)].Cells["driverid"];
dataGridView1.BeginEdit(true);

}
}

这是否有效,我尚未测试,因为我没有数据可供测试

关于c# - 将光标保持在数据 GridView 的特定列内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22980328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com