Results 1 to 11 of 11

Thread: Force DataSet to update on DataGridView CellDoubleClick

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Force DataSet to update on DataGridView CellDoubleClick

    I have a DataGridView bound to a DataView. The DGV is setup for FullRowSelect and is ReadOnly. The first column contains a CheckBox to show that the Row is ready for processing. The user double-clicks on the row and the box is checked in the CellDoubleClick event. This works great.

    I have a RadioButton on the page to hide any checked items. This allows the user to only have to look at the work that needs to be done. I use a filter on the DataView to make this happen. At the end of the CellDoubleClick, I call my ApplyFilter method, but the current row still shows up.

    I got around this once before by writing some code to see if I needed to move forward or backward a row and also compared if there were any rows available, etc.

    It seems to me that this relates to the value not being persisted back to the DataSet until the CurrentRow is changed in the DGV. Is there a way to force this data back into the DataSet without having to programatically change the value directly in the DataSet?
    My.Settings.Signature = String.Empty

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: Force DataSet to update on DataGridView CellDoubleClick

    If your dgv is bound the the CORRECT way of doing this is apply filtering on your undelying dataset, not the dgv.
    You can use DataTable.DefaultView.RowFilter property to apply the filter you need.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Force DataSet to update on DataGridView CellDoubleClick

    DataSet.DataTable.DefaultView renders a DataView. Therefore, the results are the same. I tested it anyway, and it was the same result.
    My.Settings.Signature = String.Empty

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Force DataSet to update on DataGridView CellDoubleClick

    I think you might need to find a way to force the grid out of edit mode... then the changes should find their way into the datatable. I don't use the DGV (I use Infragistic's grid) so I am not sure where to tell you to begin looking.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Force DataSet to update on DataGridView CellDoubleClick

    I am reviewing Mark Rideout's DataGridView FAQ right now hoping to find something from the innerworkings of the DGV.
    My.Settings.Signature = String.Empty

  6. #6
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Force DataSet to update on DataGridView CellDoubleClick

    Try using the CellValueChanged Event to apply the filter.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Force DataSet to update on DataGridView CellDoubleClick

    Same result.

    I am tempted to use ProcessTabKey(True) and then ProcessTabKey(False). However, I will resist that option.
    My.Settings.Signature = String.Empty

  8. #8
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Force DataSet to update on DataGridView CellDoubleClick

    How are you updating the dataset?

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Force DataSet to update on DataGridView CellDoubleClick

    The DataSet is bound to the DGV via the DataView. All of the updating is happening behind the scenes. I'm just not sure where the actual moving of data from the display of the DGV to the DataSet happens, or how to force this to happen.
    My.Settings.Signature = String.Empty

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Force DataSet to update on DataGridView CellDoubleClick

    I opted to use DataTable.FindByPrimaryKey and set it directly in the DataTable. That wasn't what I wanted to do, but it was the cleanest of the options I could find.
    My.Settings.Signature = String.Empty

  11. #11
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Force DataSet to update on DataGridView CellDoubleClick

    If you know that the datatable is being updated, you can refresh the dgv directly after the dataset has been updated thus:

    Code:
    tableadapter.clearbeforefill=true
    tableadapter.fill(recordset.dataset)
    and then apply the filter.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

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