zoukankan      html  css  js  c++  java
  • 双击dataGridView单元格显示详细信息

      //Form1

     public DataGridViewRow dataGridViewRow;//在修改中用到该变量,用来传送要修改的记录信息

     private void dataGridView1_DoubleClick(object sender, EventArgs e)
            {
                //得到当前行
                dataGridViewRow = dataGridView1.CurrentRow;
                if (dataGridViewRow != null)
                {
                    //修改当前信息
                    RenYuan ren = new RenYuan();
                    ren.ShowDialog(this);
                }
              
            }

            private void button1_Click(object sender, EventArgs e)
            {
                using(SqlConnection con=new SqlConnection("server=.;uid=sa;pwd=sa;database=xiaoxiDemo"))
                {
                    SqlDataAdapter da = new SqlDataAdapter("select * from xi",con);
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    this.dataGridView1.DataSource = dt;
                    con.Close();
                }
              
            }
        }

    //Form2

     private void RenYuan_Load(object sender, EventArgs e)
            {
                this.txtID.Text = ((Form1)(this.Owner)).dataGridViewRow.Cells[0].Value.ToString();
                this.txtSex.Text = ((Form1)(this.Owner)).dataGridViewRow.Cells[1].Value.ToString();
                this.txtAge.Text = ((Form1)(this.Owner)).dataGridViewRow.Cells[2].Value.ToString();
            }

  • 相关阅读:
    使用libmap
    仿真 vcs/ncverilog
    git——git不常见指令记录
    Mac更换鼠标指针样式_ANI、CUR文件解析
    油猴脚本——CSDN防复制破解
    解决Establishing SSL connection without server‘s identity verification is not recommended.
    IDEA激活 试用30天 自动激活
    IDEA Plugins:Free Mybatis plugin(Mapper跳转XML)安装及使用
    Springboot异常汇总
    springbootdemo
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/1298562.html
Copyright © 2011-2022 走看看