Help with clearing rows in DataGridView using VB.NET

Hi,

When I click rows on Grid1 I display results in Grid2, but when I uncheck the rows in Grid1, how do I clear the rows in Grid2?

Thanks,

Victor
vcharlesAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
To your question, "When I click rows on Grid1 I display results in Grid2, but when I uncheck the rows in Grid1, how do I clear the rows in Grid2?", try the following :

Grid2.DataSource = Nothing
0
 
Fernando SotoRetiredCommented:
Hi Victor;

Is this a web form a Windows form a WPF application?
Is this a master detail data grid view?
It would help to see the code.
0
 
Kishan ZunjareSr. Software EngineerCommented:
You no need to clear rows of Grid2, if you don't want to show Grid2, You can just hide/show Grid2 on click of checkbox of Grid1.

Or here you can use Expand/collapse functionality;
http://www.aspsnippets.com/Articles/Nested-GridView-Example-in-ASPNet-using-C-and-VBNet.aspx

-Kishan
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
vcharlesAuthor Commented:
Hi,

It is a windows application inn VS 2010, using the DataGridView. I would prefer to clear the rows than hide the Grid if possible.

V.
0
 
Fernando SotoRetiredCommented:
Is this a master detail data grid view?
It would help to see the code.
0
 
vcharlesAuthor Commented:
Hi,

Below is the code I'm using in c1valuechange event of C1Screen2 to load C1Screen3.

 Dim FilteredDTA As DataTable
        Dim DVA As New DataView(dtsetLinkAOP5.Tables(0), SearchCriteria, Nothing, DataViewRowState.CurrentRows)
        FilteredDTA = DVA.ToTable
        If FilteredDTA.Rows.Count > 0 Then
        Me.C1Screen3.DataSource = FilteredDTA.DefaultView.ToTable(True, New String() {"COUNTRY", "FIF", "NAS", "QUANTITY", "PC"})
End If
0
 
vcharlesAuthor Commented:
It works.

Thanks.

V.
0
 
Fernando SotoRetiredCommented:
Not a problem, glad I was able to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.