Click here to Skip to main content
15,891,783 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Before I save or change data in a row/column on my datagrid I have to move off of the row/column before it is submitted to the DB.

Normally this is ok but I'm adding a filepath to a cell which is obtained via openfiledialogue. After I close the openfiledialogue the filepath dosnt show in the datagrid cell until I move off of the highlighted cell, this makes for tricky data entry.

How can I force the data to be submitted say with a button click or make the highlighted cell be the next row.?

Hope that makes sense

thankx for looking

Ok, so it seems it is harder to make ppl understand the problem fully than actualy solve it.

So Im thinking something along the lines of using a button click and code like this

Private Sub CmdNext_Click(sender As System.Object, e As System.EventArgs) Handles CmdNext.Click
Me.MyBindingSource.MoveNext() 'THIS MOVES THE FOCUS TO THE NEXT CELL
End Sub


the grid is now updated it WORKS.

SO THANKS TO YOU WHO MADE A CONTRIBUTION HERE AND I HOPE THIS WILL HELP SOMEONE IN THE FUTURE
Posted
Updated 3-Jan-12 12:35pm
v9
Comments
Sergey Alexandrovich Kryukov 3-Jan-12 13:38pm    
Please, give use fully-qualified name of the DataGridView type and tag your UI library and type of application (WPF, Silverlight, Forms, ASP.net, what?!).
--SA
Kschuler 3-Jan-12 14:24pm    
Can you post the code you are currently using to put the text into the cell? It might help us understand the issue.
It is what it is 3-Jan-12 14:46pm    
ok for what its worth, but I think its beside the point :)
I mean as far as im concerned there is no code, the data in the cell is submitted after you move off of the cell, this behaviour must be part of what happens under the covers with a datagridview yes??

In the code below I use a field from details view to hold the string, I'm using a gridview and details view on the same form, sorry its hard to explain.




Private Sub CmdInsertImage_Click(sender As System.Object, e As System.EventArgs) Handles CmdInsertImage.Click

OpenFileDialog1.ShowDialog()
FilePathTextBox.Text = OpenFileDialog1.FileName
'assign filename to FilepathTextBox. This field is derived from a details view
'that comes from the dataset.
TxtFileName.Text = OpenFileDialog1.SafeFileName 'not important
ImagePictureBox.Image = Image.FromFile(FilePathTextBox.Text) 'not important
DatestampDateTimePicker.Value = Now 'not important

End Sub
Kschuler 3-Jan-12 14:53pm    
hm...so where in that code are you assigning a value to a datagridviewcell? You don't seem to be referencing a DataGrid anywhere in that code. It looks like you are just assigning the value to a textbox (The one you marked as "derived" from a details view, and I'm not sure what that means.) Could you explain some more? Also, you can click the "Improve Question" button and add this code and more information to your original question. That way people don't have to read all of the comments to find new info.
It is what it is 3-Jan-12 15:02pm    
"derived" from a details view, and I'm not sure what that means

when u add a datasource you can drag a gridview onto the form. There is also an option the have the display set to details

You can also have gridview and details the same form that is how I'm working......

1 solution

after the return of the dialog, you assing the data to the cell, if this is ok, after that, you can use this instruction to end the edition.

datagridview1.Endedit(true)


regards.
 
Share this answer
 
Comments
It is what it is 8-Jan-12 1:58am    
Thank you for your suggestion, I will include this in my project to see if it works and get back to you. I'm happy you can understand the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900