数据网格更新 [英] datagrid updation
本文介绍了数据网格更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想停止输入键以转到下一行,而我希望它转到C#.NET(3.5)的datagridview中的下一个单元格
如何停止游标执行此操作?
这是代码:
I want to stop enter key to go the next row rather I want it to go to next cell in a datagridview in C#.NET(3.5)
How I stop cursor to do that?
Here is the code:
private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
{
try
{
dataGridView1.Refresh();
int Secondrowindex = Convert.ToInt32(dataGridView1.CurrentRow.Index);
int rowcounter = dataGridView1.Rows.Count;
int asd = Convert.ToInt32(dataGridView1.CurrentCell.ColumnIndex);
if (asd <= 5 && Secondrowindex == rowcounter - 1)
{
if (e.KeyCode == Keys.Enter)
{
if (asd == 5)
{
dataGridView1.CurrentCell = dataGridView1[dataGridView1.CurrentCell.ColumnIndex - 4, dataGridView1.CurrentRow.Index];
}
else if (asd == null)
{
}
else
{
string asew= dataGridView1.EditMode.ToString();
Console.WriteLine(dataGridView1.CurrentCell.EditedFormattedValue);
dataGridView1.CurrentCell = dataGridView1[dataGridView1.CurrentCell.ColumnIndex + 1, dataGridView1.CurrentRow.Index];
}
}
}
else if (asd == 5 && rowcounter == Secondrowindex + 1)
{
if (e.KeyCode == Keys.Enter)
{
dataGridView1.CurrentCell = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex + 1];
}
}
else
{
}
}
catch (Exception gf)
{
Console.WriteLine(gf.StackTrace);
}
}
推荐答案
请参阅本页中的文章,该文章适用于VB.Net,但您可以将其移植到C#
http://arsalantamiz.blogspot.com/2008/07/making- enter-key-move-to-next.html [ ^ ]
See the article in this page, this is for VB.Net, but you will be able to port it across to C#
http://arsalantamiz.blogspot.com/2008/07/making-enter-key-move-to-next.html[^]
这篇关于数据网格更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文