Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

How to add DataColumns by looping through DataGridViewCheckBoxColumn

$
0
0
I have two forms in my project. They are named "Criteria" and "Screen". The Criteria form contains DataGridViewCriteria. The Screen form contains DataGridViewScreen.

DataGridViewCriteria's first column is a CheckBoxColumn. DataGridViewCriteria's second column contains a description specific to each row. I need to loop through the CheckBoxColumn and for each CheckBox that is checked I need to add a DataColumn to DataGridViewScreen. I need the title of each DataColumn added to DataGridViewScreen to equal the description that is adjacent its respective CheckBox on DataGridViewCriteria.

My code so far is:
Code:

For Each row As DataGridViewRow In Criteria.DataGridViewCriteria.Rows
        If row.Cells(1).Value = True Then
            Dim col As New DataColumn(row.Cells(1).Value, Type.GetType("System.String"))
            dt.Columns.Add(row.Cells(1).Value)
        End If
    Next

Any suggestions?

Thank you very much!

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>