Results 1 to 6 of 6

Thread: [RESOLVED] DataGridViewCheckBoxCell...

  1. #1

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Resolved [RESOLVED] DataGridViewCheckBoxCell...

    Hi all.

    How do I get the value of checkboxcell in DataGridView control?

    the value,TrueValue,FalseValue always return as null...
    in the column I set the TrueValue to "true" and the FalseValue to "false"
    this is the first time i'm trying to access this control so I must doing something wrong here.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: DataGridViewCheckBoxCell...

    You don;t need to set the TrueValue and FalseValue because they will be True and False by default. It's only if you want something other than those defaults, e.g. "Yes" and "No", that you need to set them explicitly. As for getting the value, just like every other cell in a DataGridView, it's the Value property yo want. If you aren't getting the correct data then you must be doing it wrong. As you haven't shown us what you're doing, we can't say what that might be.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: DataGridViewCheckBoxCell...

    the Value Property of the cell is always null, I try to get the value from the CellClick event..
    now that I think about it, do I get the value of the cell and not of the CheckBox Control?

    is there click event for the DataGridViewCheckbox control? I will check it now.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  4. #4

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: DataGridViewCheckBoxCell...

    Ok, got it working.

    Thanks.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [RESOLVED] DataGridViewCheckBoxCell...

    There is no CheckBox control. The cell simply contains a rendering of a check box.

    What do I always say? Read the documentation.
    If you want to respond immediately when users click a check box cell, you can handle the DataGridView.CellClick event, but this event occurs before the cell value is updated.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: [RESOLVED] DataGridViewCheckBoxCell...

    Yes John I agree and trust me I'm doing a lot of reading, but sometimes you just needs to get the job done as fast as you can and move on. (and this is exactly one of those time ehe)

    The problem was that I didn't set the DataGridViewCheckBoxCell default value when I initialize it.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

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