DataGridView 取得当前单元格的内容实现模糊查找

提醒:本方法主要是在一个界面不弹窗体情况下实现的

private void dataGridView2_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows[connectClass.form2X].Cells[connectClass.form2Y].Value = 
                dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells[2].Value.ToString();
            this.panel1.Visible = false;            //将panel再度隐藏
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "button1 has click!";
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int dgvX = dataGridView1.Location.X;
            int dgvY = dataGridView1.Location.Y;

            int cellX = this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location.X 
                + this.dataGridView1.Location.X;
            int cellY = this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location.Y
                + this.dataGridView1.Location.Y;

            connectClass.form2X = e.RowIndex;
            connectClass.form2Y = e.ColumnIndex;                                 //获取要编辑单元格位置
            panel1.Location = new Point(cellX, cellY+25);                      //(全屏的情况下)获取当前修改单元格位置便于panel显示
            panel1.Visible = true;                                            //将panel显示
        }

原文地址:https://www.cnblogs.com/jamse/p/3381553.html