单击按钮时,如何在datagridview顶部添加新的空行 [英] How to add a new blank row at top of the datagridview when I click button

查看:72
本文介绍了单击按钮时,如何在datagridview顶部添加新的空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在slno文本框中有一个datagridview,startno textbox,noofcheques combobox和endingno,status。我已经创建了设计时。现在我想要的是当我点击添加按钮时在datagridview的顶部添加空行。请发布帮助我这个。我试过这个代码得到slno列无法找到。谢谢提前。



我尝试了什么:



I have a datagridview in that slno textbox,startno textbox,noofcheques combobox and endingno,status.I have create while design time.Now i want is when i click add button add blank row at top of the of the datagridview.Please help me on this.i have tried this code getting slno column could not be found.Thanks in advance.

What I have tried:

private void btnadd_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = new DataGridViewRow();
            row.Cells["Slno"].Value = null;
            row.Cells["startno"].Value = null;
            row.Cells["noofcheques"].Value = null;
            row.Cells["endingno"].Value = null;
            row.Cells["Status"].Value = null;
            dgvwChqs.Rows.Insert(0, row);
           
        }

推荐答案

参见 DataGridViewRowCollection.Insert方法(Int32,DataGridViewRow)(System.Windows.Forms) [ ^ ]。


这篇关于单击按钮时,如何在datagridview顶部添加新的空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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