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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值