我在小组内设立了一个由方案组成的小组,是我的数据网格,也是方案性的。 它列出了供应商名单,我希望就这一数据进行<编码>CellDoubleClick的活动,以便获得其身份证,小组和数据网格将隐藏/储存。 我如何能够这样做?
DataGridView dgvSupp;
private void cbSuppID_Click(object sender, EventArgs e)
{
pGeneral.Controls.RemoveByKey("pCatHierarchy");
Panel pSupp = new Panel();
pSupp.Size = new System.Drawing.Size(239, 196);
pSupp.Location = new Point(152, 173);
pSupp.Name = "pSupplier";
pSupp.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Controls.Add(pSupp);
pSupp.BringToFront();
dgvSupp = new DataGridView();
dgvSupp.AllowUserToAddRows = false;
dgvSupp.AllowUserToDeleteRows = false;
dgvSupp.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvSupp.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;
dgvSupp.Dock = System.Windows.Forms.DockStyle.Fill;
dgvSupp.MultiSelect = false;
dgvSupp.ReadOnly = true;
dgvSupp.RowHeadersVisible = false;
dgvSupp.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
pSupp.Controls.Clear();
pSupp.Controls.Add(dgvSupp);
DataTable dt = pc.fetchRecord("VIEW", "FETCHCBSUPP", "", "", "", "", "", "");
BindingSource source = new BindingSource();
source.DataSource = dt;
dgvSupp.DataSource = source;
}
我曾尝试过这样的情况,即你拖拉,放弃数据网格,点击事件性质,不工作。
private void dgvSupp_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = dgvSupp.Rows[e.RowIndex];
txtID.Text = row.Cells["Supplier ID"].Value.ToString();
}