日期:2014-05-17 浏览次数:20772 次
private void DataGridview1_CellClick(object sender, DataGridViewCellEventArgs e) { int count = this.DataGridview1.Rows.Count; if (count != 0) { id = Convert.ToInt32(this.DataGridview1[0, DataGridview1.CurrentCell.RowIndex].Value); txtxm.text = this.DataGridview1[1, DataGridview1.CurrentCell.RowIndex].Value.ToString(); txtsex.Text = this.DataGridview1[2, DataGridview1.CurrentCell.RowIndex].Value.ToString(); txtold.Text = this.DataGridview1[3, } }
------解决方案--------------------
gridView点击事件
{
this.姓名文本框.Text = this.gridView.SelectedItems[0].subItem[0].text;
this.性别文本框.Text =this.gridView.SelectedItems[0].subItem[1].Text;
this.年龄文本框.text = this.gridView.SelsectedItems[0].subItem[2].text;
}
要注意subItem[n] n的值