|
-
Jul 29th, 2010, 02:38 PM
#1
Thread Starter
Fanatic Member
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
-
Jul 29th, 2010, 02:49 PM
#2
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.
-
Jul 29th, 2010, 02:54 PM
#3
Thread Starter
Fanatic Member
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
-
Jul 29th, 2010, 02:56 PM
#4
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
-
Jul 29th, 2010, 03:00 PM
#5
Thread Starter
Fanatic Member
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
-
Jul 29th, 2010, 03:08 PM
#6
Hyperactive Member
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. 
-
Jul 29th, 2010, 03:12 PM
#7
Thread Starter
Fanatic Member
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
-
Jul 29th, 2010, 03:19 PM
#8
Hyperactive Member
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. 
-
Jul 29th, 2010, 03:21 PM
#9
Thread Starter
Fanatic Member
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
-
Jul 29th, 2010, 03:39 PM
#10
Thread Starter
Fanatic Member
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
-
Jul 29th, 2010, 03:47 PM
#11
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|