''''''**************************************DataGridView ?? 我在DataGridView中进行直接修改,,,当我修改到主键重复的时候,,我进行了判断,,,我是在主键修改之后就判断的...请我判断之后,,如果重复,,,,''''如何使其鼠标返回到原来的位置哦............ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在DataGridView上,,,显示的数据为表A中的 表A的主键为ID,,,,,当我点击修改ID时,,,修改ID后,,我点击另外一个单元格,,他就要进行判断ID是否重复,,,,,,重复的我就想使鼠标又跳到ID这格单元格上哦........................??就是怎样上他跳到原来地单元上哦 ................. 这是我的解决方法: this.dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError); private void dataGridView1_DataError(object sender,DataGridViewDataErrorEventArgs e) { if (e.Exception != null && e.Context == DataGridViewDataErrorContexts.Commit) { MessageBox.Show("用户ID已存在。"); } } datagridview 自带一个DataError事件可以判断,但要等到这一行输入完成后,如果你想让一离开单元格就判断的话就要在 this.dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);中自己验证 private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { ...... } foreach (DataGridViewRow dgwellrow in dataGridView1.Rows) { foreach (DataGridViewCell cell in dataGridView1.Cells) { // Very important // Let current cell lose focus dataGridView1.CurrentCell = null; if (cell.ColumnIndex == 2) { if (判断存在) { // Select current cell dataGridView1.CurrentCell = cell; dataGridView1.BeginEdit(false); dataGridView1.CurrentRow.ReadOnly = false; Utility.ShowInformation("你输入的ID号已存在,请核对后重新输入!"); return false; } } } } 定义一对int i, j, 用来保存原来的位置, 如果重复, 则dataGridView1.CurrentCell=dataGridView1.Rows[i].Cells[j]; WPF统一设置Style的问题 关于考程序员证书问题 反射如何获得实体层 select max(a) as b from c where id='d' Remoting 传递自定义对象列表问题 急!!!!!! 菜鸟级问题:如何打开一个窗口? treeview控件的使用 (c/s)如何在TreeView的节点中单击右键弹出一个快捷菜单? 这是什么回事?无效的 CurrentPageIndex 值。它必须大于等于 0 且小于 PageCount 这里到底有没有斑竹??? 用什么语言做外挂比较好 大家帮我看看下面这句SQL语言哪里错了,我怎么也没查出原因
this.dataGridView1.DataError +=
new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
private void dataGridView1_DataError(object sender,DataGridViewDataErrorEventArgs e)
{ if (e.Exception != null &&
e.Context == DataGridViewDataErrorContexts.Commit)
{
MessageBox.Show("用户ID已存在。"); }
}
datagridview 自带一个DataError事件可以判断,但要等到这一行输入完成后,如果你想让一离开单元格就判断的话就要在
this.dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);中自己验证
private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
......
}
{
foreach (DataGridViewCell cell in dataGridView1.Cells)
{
// Very important
// Let current cell lose focus
dataGridView1.CurrentCell = null; if (cell.ColumnIndex == 2)
{
if (判断存在)
{
// Select current cell
dataGridView1.CurrentCell = cell;
dataGridView1.BeginEdit(false);
dataGridView1.CurrentRow.ReadOnly = false;
Utility.ShowInformation("你输入的ID号已存在,请核对后重新输入!");
return false;
}
}
}
}