求救一个关于dataGridView相关的一问题那。
SqlConnection con = new SqlConnection( "server=.;uid=haohao;pwd=power;database=smsinfo ");
SqlDataAdapter dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = new SqlCommand( "select top 13 * from userinfo ORDER BY 开户日期 DESC ", conn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "emp ");
conn.Close();
conn = null;
this.dataGridView1.DataSource = ds.Tables[ "emp "].DefaultView;
上面是绑dataGridView显示数据代码,我想用单击当中某一行就能在textbox显示这一行中某个字段值那,谢谢高手指点那。
------解决方案--------------------private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int i = e.RowIndex;
DataGridViewRow row = this.dataGridView1.Rows[i];
for (int j = 0; j < row.Cells.Count; j++)
{
row.Cells[i];
}
}
------解决方案--------------------up