自动将新行添加到datagridview [英] Automatically add a new row to a datagridview

查看:108
本文介绍了自动将新行添加到datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望自动添加datagridview上的行,而不是像我已经拥有的那样按钮,也许它可以使用标签来操作。这就是我已经拥有但只能使用一个按钮。



我尝试过:



I want the rows on the datagridview to be added automatically and not with a button like I already have, maybe it can operate using a lable instead. this is what i have already but this works only with a button.

What I have tried:

//add new row start 
        private void button4_Click(object sender, EventArgs e)
        {
            pictureBox2.Image = null;
            try
            {
                createAttendanceBindingSource.AddNew();                
                
            }
            catch
            {
                MessageBox.Show("Clear the fields by clicking clear first", "Fields Not Cleared", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

推荐答案

引用:

我希望自动添加datagridview上的行,而不是像我已经拥有的那样按钮,也许它可以使用标签来操作。这就是我已经拥有但是这可以用一个按钮。

I want the rows on the datagridview to be added automatically and not with a button like I already have, maybe it can operate using a lable instead. this is what i have already but this works with a button.



您只需要决定何时添加新行,哪个事件以及哪些条件。


You only have to decide when to add a new row, which event and which conditions.


如果你想自动添加新行然后添加





DataGridView.AllowUserToAddRows = True

在网格视图中
If you want automatically Added new row then Add


"DataGridView.AllowUserToAddRows = True"
In your Grid view


这篇关于自动将新行添加到datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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