winform中如何选中datagridview中的一行数据双击后跳转并将其显示在另一个页面的datagirdview中

2021-04-09 16:25

阅读:635

标签:public   arp   tar   选择   show   alt   ali   数据   页面   

Form1:

   public static string[] a;
  private void dataGridView1_DoubleClick(object sender, EventArgs e)//添加datagridview1的双击事件
        {
            try
            {
                int index = dataGridView1.CurrentRow.Index;
                a = new string[dataGridView1.ColumnCount];
                for (int i = 0; i
                {
                    a[i] = dataGridView1.Rows[index].Cells[i].Value.ToString();
                 }
                Form2 f2 = new Form2();
                f2.Show();
                                                                       
            }
            catch { }
        }
Form2://
  public Form2()
        {
            InitializeComponent();
            showGridView();
        }
  private void showGridView()
        {
            DataGridTextBoxColumn tb = new DataGridTextBoxColumn();
            dataGridView1.Rows.Add(tb);
            for (int i = 0; i
                dataGridView1.Rows[dataGridView1.RowCount-2].Cells[i].Value = Form1.a[i];//根据AllowUserToAddRow属性选择最后一行,true时dataGridView1.RowCount-2,false时dataGridView1.RowCount-1
        }

winform中如何选中datagridview中的一行数据双击后跳转并将其显示在另一个页面的datagirdview中

标签:public   arp   tar   选择   show   alt   ali   数据   页面   

原文地址:https://www.cnblogs.com/cnote/p/9061701.html


评论


亲,登录后才可以留言!