Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

VB
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.
Posted
Updated 28-Sep-11 14:34pm
v2

1 solution

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.
 
Share this answer
 
Comments
jayasakthi shanmuggarajah 29-Sep-11 5:32am    
aftrt using datagridrequest.Rows.Clear() also the rows are not removing only the data is getting remove

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900