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

基本问题????
在C#中
我点击datagirdview上某一行..
我要使这行的数据填充到相应的text1.text或combox.text中去..
请问怎么来写啊..
谢谢拉

------解决方案--------------------
坐着沙发等高手来解答
------解决方案--------------------
似乎有个当前焦点的属性,用这个来赋值就是!
------解决方案--------------------
int top = this.dataGrid1.CurrentCell.RowNumber;
if (top > = 0)
{
this.textBox1.Text = this.objdataset.Tables[0].Rows[top][1].ToString();
this.textBox2.Text = this.objdataset.Tables[0].Rows[top][2].ToString();
this.textBox3.Text = this.objdataset.Tables[0].Rows[top][3].ToString();
this.textBox4.Text = this.objdataset.Tables[0].Rows[top][4].ToString();
this.textBox5.Text = this.objdataset.Tables[0].Rows[top][5].ToString();
this.button3.Enabled = true;
this.button4.Enabled = true;
}
------解决方案--------------------
this.dgManualInput.CurrentRowIndex得到当前选中的数据行索引,由此可以得到其绑定的数据源DataTable或DataSet之类的某一行数据。
------解决方案--------------------
使用绑定DataBings