Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is the code I used to add textbox values to a Data Grid View.

I am getting the error that, because my first column is a Checkbox, the code is trying to add the "txtTaskName" value to it.

How can I get it to skip the Checkbox column, and add the first value to the 2nd column.

Please tell me if I need to further clarify.

UPDATE: I tried moving the checkbox column to the very right of the table. This gave me an error saying that the text box entry was not a boolean, how can I fix this?

What I have tried:

Private Sub btnAddTask_Click(sender As Object, e As EventArgs) Handles btnAddTask.Click

        dataGVGeneral.Rows.Add(txtTaskName.Text, txtTaskTag1.Text, txtTaskTag2.Text, cmbPriority.SelectedItem.ToString(), dateDUE.Value.ToString(), txtLink.Text, txtNoteEntry.Text)

    End Sub
Posted
Updated 7-Jul-20 21:58pm
v3
Comments
Andre Oosthuizen 8-Jul-20 0:45am    
See THIS here at Codeproject.

1 solution

There's few ways to achieve that. See: DataGridViewRowCollection.Add Method (System.Windows.Forms) | Microsoft Docs[^]

VB.NET
Private Sub btnAddTask_Click(sender As Object, e As EventArgs) Handles btnAddTask.Click
        Dim dgvrow As Object() = New Object(){Nothing, txtTaskName.Text, txtTaskTag1.Text, txtTaskTag2.Text, cmbPriority.SelectedItem.ToString(), dateDUE.Value, txtLink.Text, txtNoteEntry.Text}
        dataGVGeneral.Rows.Add(dgvRow)

    End Sub
 
Share this answer
 

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