| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 588 人关注过本帖
标题:[求助]:请教各位一个问题,DataGrid的CurrentCellChange事件
只看楼主 加入收藏
mac110
Rank: 1
等 级:新手上路
帖 子:54
专家分:0
注 册:2005-8-31
收藏
 问题点数:0 回复次数:0 
[求助]:请教各位一个问题,DataGrid的CurrentCellChange事件
具体是这样的:窗体初始化的时候,将光标焦点停留在DataGrid的一个Cell中(只有这个Cell是可以编辑的),其他都是只读的。用户要求输入这个单元格数值后,按“回车键”,光标跳到下一行的同列上,同时更新上一行的其他Cell中的信息,应该使用CurrentCellChange事件吧,问题是:出现了DataGrid的CurrentRowIndex的相关的循环,而光标总是停在第一个位置不动。
下面是CurrentCellChange事件代码
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
int i_Index = this.dataGrid1.CurrentCell.RowNumber;
int i_column = this.dataGrid1.CurrentCell.ColumnNumber;
int i_Num = 0;
if(i_Index == 0 )
{
return;
}
string strNum = this.dataGrid1[i_Index-1,14].ToString().Trim();
if(strNum != "")
{
try
{
i_Num = System.Convert.ToInt32(strNum);
string str_Kc = this.dataGrid1[i_Index-1,4].ToString().Trim();
if(str_Kc != "")
{
//this.dataGrid1[i_Index-1,4] = System.Convert.ToString(System.Convert.ToInt32(str_Kc)-i_Num);
}
}
catch(Exception error)
{
MessageBox.Show(error.Message.ToString() + "请输入数字格式");
// DataGridCell cell = new DataGridCell(i_Index-1,14);
// this.dataGrid1.CurrentCell = cell;
return;
}
}
else
{
return;
}
}
各位看看 帮忙解决下 谢谢
搜索更多相关主题的帖子: DataGrid 
2007-08-02 18:15
快速回复:[求助]:请教各位一个问题,DataGrid的CurrentCellChange事件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014288 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved