We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

checkbox in datagrid stays greyed out..

Hi I have created a windows form that hold a datagrid, that datagrid gets it values from a stored procedure. My problem is that I have added a checkbox to the datagrid and applied some style to the datagrid. But the checkbox is always greyed out. Why is that, and what am I doing wrong? Here''s my code... Sub BindData(ByVal OrderID As String) Dim myConnection As SqlConnection Dim myCommand As SqlCommand Dim myDataAdapter As SqlDataAdapter Dim myDataSet As New DataSet Dim strConn As String strConn = ("myconnstr") myConnection = New SqlConnection(strConn) myConnection.Open() myCommand = New SqlCommand("p_PDFDetail", myConnection) myCommand.CommandType = CommandType.StoredProcedure myCommand.Parameters.Add("@CartID", SqlDbType.NVarChar, 50).Value = OrderID myDataAdapter = New SqlDataAdapter(myCommand) myDataAdapter.Fill(myDataSet, "tbl_Order") Dim myDataTable As New DataView(myDataSet.Tables("tbl_Order")) myDataSet.Tables("tbl_Order").Columns("InfileMap").ColumnMapping = MappingType.Hidden Dim ts1 As New DataGridTableStyle ts1.MappingName = "tbl_Order" ts1.AlternatingBackColor = Color.LightGray Dim TextCol1 As New DataGridTextBoxColumn Dim TextCol2 As New DataGridTextBoxColumn Dim TextCol3 As New DataGridTextBoxColumn Dim TextCol4 As New DataGridTextBoxColumn Dim TextCol5 As New DataGridTextBoxColumn TextCol1.MappingName = "CartID" ''from dataset table TextCol1.HeaderText = "OrderID" TextCol1.Width = 100 TextCol2.MappingName = "Quantity" ''from dataset table TextCol2.HeaderText = "Qty" TextCol2.Width = 50 TextCol2.Alignment = HorizontalAlignment.Center TextCol3.MappingName = "ArtNr" ''from dataset table TextCol3.HeaderText = "Article nr" TextCol3.Width = 75 TextCol4.MappingName = "Description" ''from dataset table TextCol4.HeaderText = "Product" TextCol4.Width = 250 TextCol5.MappingName = "Country" ''from dataset table TextCol5.HeaderText = "Language" TextCol5.Width = 100 ts1.GridColumnStyles.Add(TextCol1) ts1.GridColumnStyles.Add(TextCol2) ts1.GridColumnStyles.Add(TextCol3) ts1.GridColumnStyles.Add(TextCol4) ts1.GridColumnStyles.Add(TextCol5) MyDataGrid.DataSource = myDataSet ''MyDataGrid.AlternatingBackColor = Color.LightGray MyDataGrid.TableStyles.Add(ts1) MyDataGrid.ReadOnly = True ''STEP 4: Add the checkbox Dim boolCol As New DataGridBoolColumn With boolCol .HeaderText = "Make PDF" .MappingName = "ID" .Width = 75 .TrueValue = True .FalseValue = False .ReadOnly = False .Alignment = HorizontalAlignment.Center .AllowNull = False End With ts1.GridColumnStyles.AddRange(New DataGridColumnStyle() {boolCol}) MyDataGrid.TableStyles.Add(ts1) MyDataGrid.DataMember = "tbl_Order" End Sub Regards Magnus

Loader.
Up arrow icon