单击vb.net 2008中的清除按钮后,减少datagridview中的行 [英] decreasing rows in datagridview after clicking clear button in vb.net 2008

查看:162
本文介绍了单击vb.net 2008中的清除按钮后,减少datagridview中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用datagridview.我正在使用此代码清除行.项目仅在清除,但行仍在

I am using datagridview in my project. I am using this code to clear rows.the items are only clearing but the rows are remaining

btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
        
        For j As Integer = 0 To datagridrequest.Rows.Count - 1
            datagridrequest.Rows(j).Cells(Column1).Value = ""
            datagridrequest.Rows(j).Cells(Column2).Value =""   
            datagridrequest.Rows(j).Cells(Column4).Value = ""
            datagridrequest.Rows(j).Cells(Column5).Value =""
        Next
    End Sub



请给我这两个行以及要清除的添加项的解决方案.



pls give me solution to both rows and added items to be cleared.

推荐答案

您可以使用datagridrequest.Rows.Clear()方法清除所有行.但是,如果您的DataGridView是数据绑定的,并且您的数据源不支持清除数据,则该方法将不起作用.如果要清除它,可以将DataSource 属性设置为无.
You can use datagridrequest.Rows.Clear() method to clear all rows. However, if your DataGridView is databound and your data source does not support clearing the data, that method wont work. You can probably set your DataSource property to none if you want to clear it.


这篇关于单击vb.net 2008中的清除按钮后,减少datagridview中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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