Results 1 to 13 of 13

Thread: [RESOLVED] VB.net DataGridView CellContentClick and CellValueChanged

Hybrid View

  1. #1
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: VB.net DataGridView CellContentClick and CellValueChanged

    Read the remarks section for CellValueChanged

    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Specifically

    In the case of check box cells, however, you will typically want to handle the change immediately. To commit the change when the cell is clicked, you must handle the DataGridView.CurrentCellDirtyStateChanged event. In the handler, if the current cell is a check box cell, call the DataGridView.CommitEdit method and pass in the Commit value.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2013
    Posts
    178

    Re: VB.net DataGridView CellContentClick and CellValueChanged

    Yes, I read that already but don't understand it. Do you have an example?

    I am handling the DataGridView.CommitEdit already. How/Where do I handle the CurrentCellDirtyStateChanged event? How do I isolate a checkbox column from a text column other than by columnIndex. Why does it randomly choose between the two?

    Edit: I have been experimenting with these methods and they seem to work well and good when you only have one editable column. It's when you introduce two different types of columns that it randomly choose between the two. I tried to isolate them by identifying the columnIndex. Is there a different way to isolate the columns or edit events?
    Last edited by Fedaykin; Jan 6th, 2016 at 12:29 PM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2013
    Posts
    178

    Re: VB.net DataGridView CellContentClick and CellValueChanged

    I continue to struggle with this and every forum out there quotes the same:


    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Specifically

    In the case of check box cells, however, you will typically want to handle the change immediately. To commit the change when the cell is clicked, you must handle the DataGridView.CurrentCellDirtyStateChanged event. In the handler, if the current cell is a check box cell, call the DataGridView.CommitEdit method and pass in the Commit value.
    But this does not resolve the issue of multiple editable columns. The e.ColumnIndex remains 'stuck' on the first column integer edited. I tried setting the e.ColumnIndex to a variable and then setting that variable to -1 at the end of the method, however the CellContentClick Handler will only remember the first column. If the fist column you edit is column 0, then all subsequent columns edited will also fire 0 no matter which column is selected. Only disposing the DataGridView and recalling it will make it forget the last column fired.

    This appears to be a bug because the question has been asked many times and I've yet to see a resolution. Everyone just points to the same post quoted above.

Tags for this Thread

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