关于捕捉Datagrid一个事件。 C# winformdatagrid ... Col1 Col2 ... 12 0当在Col2中录入值时,如果其值比对应Col1的值大,则提示,且焦点停留在该Col2中,等待用户的其他输入。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个问题说来复杂了....你要做的好这个事情,要从DataGridColumnStyle或直接从DataGridTextBoxColumn继承一个新的列类型,然后重写Commit方法以达到在编辑单元格的时候对用户输入的值精确的处理.不是一两句代码就写的好的.如果要是没有要求那么高,那么可以在DataGrid.CurrentCellChanged 事件 来处理这个事情. thanks.我要在哪个方法中处理如果录入的值不合理,焦点就停留在该Cell中?请赐教。 举个例子,CurrentCellChanged事件private void Handle_CurrentCellChanged(object sender, System.EventArgs e) { newCurrentRow = dataGrid1.CurrentCell.RowNumber; newCurrentCol = dataGrid1.CurrentCell.ColumnNumber; string newText = dataGrid1[oldCurrentRow, oldCurrentCol].ToString(); if( !IsValidValue(oldCurrentRow, oldCurrentCol, newText)) { MessageBox.Show("Entry Error"); dataGrid1.CurrentCell = new DataGridCell(oldCurrentRow, oldCurrentCol); } oldCurrentRow = newCurrentRow; oldCurrentCol = newCurrentCol; } IsValidValue函数就可以判断这个col2的值的关系了。应该可以实现 关于利用system.net.mail命名空间发送邮件的一个问题 在线等,急。。。。。 小菜求助:关于登录时回车的设置 C#有关于快捷菜单 记录集怎么使用? 调色板的Entries长度为什么为零 c# Remoting 问题消息队列来看 我的代码已经添加了事件btnEditRptTemplate_Click,为何有时候又产生了btnEditRptTemplate_Click_1事件? 关于out的使用问题: 100分紧急求助:如何在C#中使用SQLDMO 用C#和SQL2000做一个简单的排课系统 工作流
你要做的好这个事情,要从DataGridColumnStyle或直接从DataGridTextBoxColumn继承一个新的列类型,然后重写Commit方法以达到在编辑单元格的时候对用户输入的值精确的处理.
不是一两句代码就写的好的.如果要是没有要求那么高,那么可以在DataGrid.CurrentCellChanged 事件 来处理这个事情.
我要在哪个方法中处理如果录入的值不合理,焦点就停留在该Cell中?
请赐教。
private void Handle_CurrentCellChanged(object sender, System.EventArgs e)
{
newCurrentRow = dataGrid1.CurrentCell.RowNumber;
newCurrentCol = dataGrid1.CurrentCell.ColumnNumber;
string newText = dataGrid1[oldCurrentRow, oldCurrentCol].ToString();
if( !IsValidValue(oldCurrentRow, oldCurrentCol, newText))
{
MessageBox.Show("Entry Error");
dataGrid1.CurrentCell = new DataGridCell(oldCurrentRow, oldCurrentCol); }
oldCurrentRow = newCurrentRow;
oldCurrentCol = newCurrentCol;
}