Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:18:11+00:00 2026-06-17T06:18:11+00:00

I am unable to correctly populate a DataGridView checkbox column from a boolean column

  • 0

I am unable to correctly populate a DataGridView checkbox column from a boolean column from a database.

First form_load code:

Me.DataGridView1.DataSource = Me.bindingSource1
GetData("SELECT myInt, myBool, myString " & _
        "FROM " & myFavTable & " " & _
        "WHERE (myInt > 100) ORDER BY myString")

formatGrid()

In GetData I fill myTable with data:

Me.dataAdapter.Fill(myTable)
Me.bindingSource1.DataSource = myTable

And finally I format grid the before showing.

I format it manually because loading is much faster than with automatic formatting.

    With DataGridView1
        .AllowUserToAddRows = False
        .AllowDrop = False
        .AllowUserToOrderColumns = False
        .AllowUserToResizeRows = False
        .SelectionMode = DataGridViewSelectionMode.FullRowSelect
        .MultiSelect = False
        .Dock = DockStyle.Fill
        .EditMode = DataGridViewEditMode.EditProgrammatically

       With .Columns(0)
            .Name = "postN"
            .HeaderText = "Postal"
            .Width = 55
        End With

        With .Columns(1) 'here should be a checkbox
            .Width = 20
        End With

        With .Columns(2)
            .Name = "colCity"
            .HeaderText = "City"
            .Width = 180
        End With
    End With

But with this code, in my column that should show checkboxes the string value 0 is displayed when in database is FALSE.

How in this situation can I get checkboxes in the middle column instead of text?

I try with .Columns.Add… before and after binding but with no wanted results.
That way I can get checkboxes, but in the new column.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:18:12+00:00Added an answer on June 17, 2026 at 6:18 am

    In design-time add the columns to the DataGridView and set the middle column as a CheckBoxColumn.

    Then set:

    With DataGridView1
       .AutoGenerateColumns = False
    

    Edit:
    I see the problem now. You need to set the DataPropertyName to be the same as the column.

    When you add columns to the DataGridView, in that dialog set the DataPropertyName to match the DataTable (myTable) column Names. That’s the magic behind the mapping.

    enter image description here

    Here is the code:

    DataTable dt = new DataTable();
    dt.Columns.Add("TextBoxCol");
    dt.Columns.Add("CheckBoxCol");
    DataRow dr = dt.NewRow();
    dr[0] = "Hello";
    dr[1] = false;
    dt.Rows.Add(dr);
    dr = dt.NewRow();
    dr[0] = "World";
    dr[1] = true;
    dt.Rows.Add(dr);
    dataGridView1.DataSource = dt;
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm unable to transition from index.html to any pages correctly. All transitions would show
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I'm unable to execute the following prepared statement , PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
I am using will_paginate with some complicated queries and it is unable to correctly
I am unable to get this script to function correctly. When i try to
The current architecture is based on WCF services which populate DTO objects from DB
I need to pass arguments to a Excel VBA code from JavaScript of HTA.
I'm unable to correctly create DOM elements using jQuery (1.3.2): var ev_t; $(#add-event).click(function() {
date.parse() method of groovy detects date DD and year yyyy correctly but is unable
I am in a strange situation where send_file is unable to send file correctly.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.