日期:2014-05-18  浏览次数:20699 次

谁能帮我解释下这段代码?
public   string   datag_zt(int   a)
{
string   b=this.dataGrid7[this.dataGrid7.CurrentRowIndex,a].ToString();
return   b;
}
public   int   index_d()
{
        int   bb=this.dataGrid7.CurrentRowIndex;
return   bb;
}
public   string   datag_pre(int   a)
{
string   b;
if(this.dataGrid7.CurrentRowIndex> 0)
{
this.dataGrid7.UnSelect(this.dataGrid7.CurrentRowIndex);
this.dataGrid7.CurrentRowIndex=this.dataGrid7.CurrentRowIndex-1;
b=this.dataGrid7[this.dataGrid7.CurrentRowIndex,a].ToString();

}
else
{
    b=this.dataGrid7[this.dataGrid7.CurrentRowIndex,a].ToString();
    MessageBox.Show( "上一条记录不存在! ", "提示 ",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return   b;
}
public   string   datag_next(int   a)
{
string   b;
        int   bb=frmMain.frmbd.aa-1;

if(this.dataGrid7.CurrentRowIndex <bb)
{
this.dataGrid7.UnSelect(this.dataGrid7.CurrentRowIndex);
this.dataGrid7.CurrentRowIndex=this.dataGrid7.CurrentRowIndex+1;
b=this.dataGrid7[this.dataGrid7.CurrentRowIndex,a].ToString();
}
else
{
b=this.dataGrid7[this.dataGrid7.CurrentRowIndex,a].ToString();
MessageBox.Show( "这是最后一条记录! ", "提示 ",MessageBoxButtons.OK,MessageBoxIcon.Information);  
}
return   b;
}



------解决方案--------------------
//dataGrid7中this.dataGrid7.CurrentRowIndex行,a列的值。
//dataGrid7選中的行的索引.
//dataGrid7如果選中的不是第一行則選擇上一行!
//dataGrid7如果選中的不是最後一行則選擇下一行!

------解决方案--------------------
//取当前行指定索引列的值
public string datag_zt(int a)
{
string b=this.dataGrid7[this.dataGrid7.CurrentRowIndex,a].ToString();
return b;
}
------解决方案--------------------
//当前行的索引值
public int index_d()
{
int bb=this.dataGrid7.CurrentRowIndex;
return bb;
}