hi to all
i need a help from
I'm using datagridview in my vb.net project.
in that datagridview i use check box for null value check property if the user click that how i check if the box is check or not in a number of rows and know how many check boxes are clicked also want to count. i try with my coding but it leaves the first line how i check

Dim tableid As Integer
        mydisp = New SqlDataAdapter("select max(id) from tst_m_tables", Myconnection)
        mydisp.Fill(mydst, "id")
        tableid = mydst.Tables("id").Rows(0).Item(tableid)
        For i = 0 To dgvtabledetails.Rows.Count - 1
            If dgvtabledetails.Rows(i).Cells(4).Selected = True Then
                pkeyval = 1
            Else
                pkeyval = 0
            End If
            If dgvtabledetails.Rows(i).Cells(5).Selected = True Then
                nullval = 1
            Else
                nullval = 0
            End If
            If dgvtabledetails.Rows(i).Cells(6).Selected = True Then
                indexed = 1
            Else
                indexed = 0
            End If
            gridstr = "insert into tst_m_tabledetails (tableid,fieldname,fieldtype,fieldwidth,tbpkey,tbnull,tbindex,version,purpose) values('" & _
                tableid & "','" & dgvtabledetails.Rows(i).Cells(1).Value & "','" & _
                dgvtabledetails.Rows(i).Cells(2).Value & "','" & _
                dgvtabledetails.Rows(i).Cells(3).Value & "','" & pkeyval & "','" & _
                nullval & "','" & indexed & "','1','" & dgvtabledetails.Rows(i).Cells(7).Value & "')"
            mycommand.CommandText = gridstr
            mycommand.CommandType = CommandType.Text
            mycommand.ExecuteNonQuery()
        Next

Edited 6 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

Comments
[code] tags please.

>how i check if the box is check or not in a number of rows and know how many check boxes are clicked also want to count.

...
For Each row As DataGridViewRow In DataGridView1.Rows
      If row.Cells("No").Value Then
           'Your statements
      End If
Next
...
This article has been dead for over six months. Start a new discussion instead.