troubleshooting Question

Datagridview with Linq 2 Sql - change columntype to DataGridViewCheckBoxCell()

Avatar of McGurk1
McGurk1Flag for United States of America asked on
C#Visual Basic.NET
8 Comments1 Solution997 ViewsLast Modified:
I need to change one of the columns to a checkbox rather than having it show as 'True' or 'False'.  I have been researching and find that I can '.Add' the column but it does not get the value from the database, it just sets up a 6th column with a checkbox.  The bit field that I want the data pulled from is generated as a 5th column.  Here is my code:


        Dim column As New DataGridViewCheckBoxColumn()
        column.HeaderText = "Update"

        Dim query = From h In db.mydbcontext Where h.ID = gsID _
                     Select h.ID, h.otherID, h.myDate, h.myCost, h.myBitField
        If query.Count > 0 Then
            With dgvMyDGV
                .DataSource = query
                .AutoGenerateColumns = False
                .Columns(0).Visible = False
                .Columns(1).Visible = False
                .Columns(2).HeaderText = "Date"
                .Columns(3).HeaderText = "Cost"
                .Columns(3).DefaultCellStyle.Format = "c"
                .Columns.Add(column)
             End With

             End If

Any help will be greatly appreciated!  I have been working on this column all day!!!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros