日期:2014-05-19  浏览次数:20857 次

会计软件中遇到的问题(datagrid 事件问题).
会计软件中遇到的问题(datagrid   事件问题).   大家帮忙看看

问题描述:
      我在datagrid   中的一行   输入一条   记录(摘要   科目   借   贷   ).
需要   验证   借   贷   必须正数   等等.   当我输完   借   这个字段   值是 "-1 "
再点一下   贷字段   的时候   因为借方出错(需要正的)   所以输入光标   应该还保留在借字段上
不知道该怎么实现.

代码如下:
col4.TextBox.Validated+=   new   EventHandler(TextBoxValidated);

private   void   TextBoxValidated(object   sender,   EventArgs   e)  
{
String   str   =   ((TextBox)sender).Text;
double   d   =   0d;
if(   DoubleCheck.IsDouble(str)   )
{
d   = double.Parse(str);
d   =   Math01.round(d);
}
else{
//dgPz.
}
}

------解决方案--------------------
这个用javascript客户端脚本就能实现吧。
------解决方案--------------------
private void imageShow_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = this.imageShow.HitTest(pt);
if(hti.Type == DataGrid.HitTestType.Cell)
{
this.imageShow.CurrentCell = new DataGridCell(hti.Row, hti.Column);
this.imageShow.Select(hti.Row);
}
}