WinForm中DataGridView的 CellClick 事件的代码

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {

            PackageID = this.dataGridView1["PackageID", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();

            this.txt_PackageName.Text = this.dataGridView1["PackageName", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
            this.txt_UsePrice.Text = this.dataGridView1["UsePrice", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
            this.txt_Price.Text = this.dataGridView1["Price", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
            this.txt_Validity.Text = this.dataGridView1["Validity", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
            this.comboBox_Category.Text = this.dataGridView1["Category", this.dataGridView1.CurrentCell.RowIndex].Value.ToString();
        }

原文地址:https://www.cnblogs.com/lzh_527/p/1640663.html