Results 1 to 2 of 2

Thread: DatagridBoolColumn

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    22

    DatagridBoolColumn

    Is there an equivalent to the C# DatagridBoolColumn for VB?

    Is there a way to programmaticaly create a bool checkbox column and to set the checkboxes to true or false based on the dataset values.
    I have a templatecolumn with checkboxes but how do I bind data to that column?

  2. #2
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    This will add a new bool checkbox column to your data grid then check the value of the "password" column and check the checkbox if the rows password="145":

    Code:
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Add a new check box column to your datagrid" 
            ds1.Tables(0).Columns.Add(New DataColumn("calculatedField", GetType(Boolean)))
    
            'Set the default value to false "Unchecked" 
            ds1.Tables(0).Columns("calculatedField").DefaultValue = False
    
             'Fill your dataset 
            da1.Fill(ds1)
    
             'Check your new column if the rows "password" column = 145 
            Dim i As Integer
            With ds1.Tables(0)
                For i = 0 To .Rows.Count - 1
                    If .Rows(i)("Password") = "145" Then
                        .Rows(i)("calculatedField") = True
                    End If
                Next
            End With
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width