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();
            }

  • 相关阅读:
    Poj1163 The Triangle(动态规划求最大权值的路径)
    Poj1258_Agri-Net(最小生成树)
    Poj1258_Agri-Net(最小生成树)
    Poj1218_THE DRUNK JAILER(水题)
    Poj1218_THE DRUNK JAILER(水题)
    Poj1298_The Hardest Problem Ever(水题)
    Poj1298_The Hardest Problem Ever(水题)
    Poj1012_Joseph
    Poj1012_Joseph
    Poj_1008--Maya Calendar
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/1298562.html
Copyright © 2011-2022 走看看