Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how i do show result of checkbox instead of 0 or 1 to check marck in datagridview (vb.net vbisual basic language)???????????????????
Posted
Comments
Sergey Alexandrovich Kryukov 19-Feb-14 17:15pm    
What do you mean? A check box does not show 0 or 1, it shows graphically: checked, unchecked or, optionally, indeterminate.
—SA

1 solution

VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim ds As New DataSet
       Dim i As Integer = 0
       ds = selectdata("Select * from mst_members order by member_name")

       If ds.Tables(0).Rows.Count > 0 Then
           While (i <> ds.Tables(0).Rows.Count)
               Me.DataGrid1.Rows.Add()
               Me.DataGrid1.Item(0, i).Value = ds.Tables(0).Rows(i).Item("account_no").ToString
               Me.DataGrid1.Item(1, i).Value = ds.Tables(0).Rows(i).Item("member_name").ToString
               Me.DataGrid1.Item(4, i).Value = IIf(ds.Tables(0).Rows(i).Item("member_name").ToString.StartsWith("s"), 1, 0) 'Check box column If your dataset item return value giving 1 then it will be checked other wise unchecked
               i = i + 1
           End While
       End If
       i = 0
       ds.Clear()
   End Sub
 
Share this answer
 
Comments
F. Xaver 20-Feb-14 10:10am    
IIF() is old... just use IF()

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