意思就是说,我一单击dataGridView1的某条记录,当前记录的所有值分别显示在textBox等控件上.
[此贴子已经被作者于2007-8-14 11:42:54编辑过]
正好我做过,发给你代码:
private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i <= dataGridView1.CurrentRow.Index; i++)
                {
                    txtId.Text = buyInDataSet.BuyIn.Rows[i][0].ToString();
                    txtCode.Text = buyInDataSet.BuyIn.Rows[i][1].ToString();
                    txtType.Text = buyInDataSet.BuyIn.Rows[i][2].ToString();
                    txtName.Text = buyInDataSet.BuyIn.Rows[i][3].ToString();
                    txtQuantity.Text = buyInDataSet.BuyIn.Rows[i][4].ToString();
                    txtPrice.Text = buyInDataSet.BuyIn.Rows[i][5].ToString();
                    txtBuyer.Text = buyInDataSet.BuyIn.Rows[i][6].ToString();
                    txtLimited.Text = buyInDataSet.BuyIn.Rows[i][8].ToString();
                    txtRemark.Text = buyInDataSet.BuyIn.Rows[i][9].ToString();
                }
            }
            catch
            {
                return;
            }

再给你另外一份,我刚做的
 /// <summary>
        /// 获取当前选中的行的项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
        {
            ShowTextBox();
        }
        /// <summary>
        /// 封装了获取当前选中的行的项的方法
        /// </summary>
        private void ShowTextBox()
        {
            this.textBox2.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            this.textBox3.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            if (dataGridView1.CurrentRow.Cells[2].Value.ToString() == "男")
            {
                this.radioButton1.Checked = true;
            }
            else { this.radioButton2.Checked = true; }
            this.textBox4.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
            this.textBox5.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
            this.textBox6.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
            this.textBox7.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
        }
