如何在按钮单击事件中在gridview中添加行(包括文本框,组合框,按钮) [英] how to add row(included textboxes, combobox, button) in gridview on a button click event

查看:154
本文介绍了如何在按钮单击事件中在gridview中添加行(包括文本框,组合框,按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在win表单上,我在数据网格中添加了一行。行包括一个组合框然后文本框然后再次文本框和一个按钮。现在我想在按钮点击事件上添加另一行(与上面相同)。我怎么能这样做

ON a win form I have add a Row in data grid. Row include one combo box then text box then again textbox and a button. now i want to add another row (same as above) on the button click event. how can i do this

推荐答案

你想要什么,请你解释一下:(
what you want exactly can you explain a bit more please :(


private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
              if (e.RowIndex >= 0 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() == typeof(DataGridViewButtonColumn))
              {
                  DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                  dataGridView1.Rows.Add(row);

                 // MessageBox.Show(e.ColumnIndex.ToString()+' '+e.RowIndex);
               }
             ///
              
                  //ComboColumn.DisplayMember = "Column Name";
 
 


        }


这篇关于如何在按钮单击事件中在gridview中添加行(包括文本框,组合框,按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆