Unable to read Checkbox from : DataGridView User Controls in Windows Forms

Vivek Thangaswamy 1 Reputation point

Unable to read Checkbox from : DataGridView User Controls in Windows Forms


Any solution in C#?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,820 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 47,626 Reputation points

    It works like it does for other cells. You didn't post any code so we cannot see what you've tried nor what you're trying to do but if you're data binding then you shouldn't need to read it directly anyway. DGV will bind the cell value to the boolean you're backing it with.

    But if you need to read it then you'll go to the cell that has the checkbox and read the Value property, which is an object. Cast it to a boolean (assuming only true/false values). Alternative you can cast the cell to the DataGridViewCheckBoxCell if you need something more.

    0 comments No comments

  2. Karen Payne MVP 35,031 Reputation points

    Discarding whatever you are talking about a UserControl, the following repository shows

    • How to get checked/unchecked values for the current row and all rows
    • Using a numeric column
    • Properly working with a DataGridViewComboBox

    Fine points, a DataGridView can be used unbound or setup to load from a data source, in this case a SQL-Server database tables are used. Using a DataGridView where the data source is not set is simply in 99 percent of cases is the wrong path to take.

    Couple of screenshots

    The Check button shows how to get all rows checked/unchecked while in the following method shows getting the checked/unchecked value and other properties.


    0 comments No comments