DataGridView HELL!!! what am I doing wrong
-
Ok have a simple datagridview well at Least I thought so.... its bound to a typed dataset, it does not do what its supposed to do, when I edit a cell in the row just above the new row line at the bottom and hit ENTER it creates a new bloody row but not really it only actualy creates the new row if I type something, I only wanted to edit the cell I was just in, but now eveytime I change a cell and hit enter it tries to validate the new row with no input in it after it has updated the database, how the hell do you get arroud this, also previuosly, one of my other problems was I would edit a cell and then on CellEndEdit I wanted it to update the database but it would not really run the update I stepped through the code and could see the data in the cell had changed and the tableadapter.update had run but no change to the DB at All, until I edited another cell. Please if any of you know what is goig on with the first problem of createing a new row on hitting enter in a non new row please assist. Thanks
Private Sub TRecieptsTableBindingSource_ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles **TRecieptsTableBindingSource.ListChanged** If Me.StockDB.HasChanges Then Me.UpdatePending = True End If End Sub Private Sub DataGridView1_RowValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) **Handles DataGridView1.RowValidated** If UpdatePending And ValidRow = True Then Me.TRecieptsTableTableAdapter.Update(Me.StockDB.tRecieptsTable) Me.UpdatePending = False ValidRow = False End If End Sub
-
Ok have a simple datagridview well at Least I thought so.... its bound to a typed dataset, it does not do what its supposed to do, when I edit a cell in the row just above the new row line at the bottom and hit ENTER it creates a new bloody row but not really it only actualy creates the new row if I type something, I only wanted to edit the cell I was just in, but now eveytime I change a cell and hit enter it tries to validate the new row with no input in it after it has updated the database, how the hell do you get arroud this, also previuosly, one of my other problems was I would edit a cell and then on CellEndEdit I wanted it to update the database but it would not really run the update I stepped through the code and could see the data in the cell had changed and the tableadapter.update had run but no change to the DB at All, until I edited another cell. Please if any of you know what is goig on with the first problem of createing a new row on hitting enter in a non new row please assist. Thanks
Private Sub TRecieptsTableBindingSource_ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles **TRecieptsTableBindingSource.ListChanged** If Me.StockDB.HasChanges Then Me.UpdatePending = True End If End Sub Private Sub DataGridView1_RowValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) **Handles DataGridView1.RowValidated** If UpdatePending And ValidRow = True Then Me.TRecieptsTableTableAdapter.Update(Me.StockDB.tRecieptsTable) Me.UpdatePending = False ValidRow = False End If End Sub
Sorry, I have no idea, that's because I do not allow in line editing in any grid, I force the user to edit in either a detail panel or another form. The VERY few exceptions to this I only allow editing so the DGV addrows is disabled. IMHO the management of grid inserting/editing is a bloody nightmare, always has been and I'm not convinced they have it right yet.
Never underestimate the power of human stupidity RAH
-
Sorry, I have no idea, that's because I do not allow in line editing in any grid, I force the user to edit in either a detail panel or another form. The VERY few exceptions to this I only allow editing so the DGV addrows is disabled. IMHO the management of grid inserting/editing is a bloody nightmare, always has been and I'm not convinced they have it right yet.
Never underestimate the power of human stupidity RAH
Yeah I reckon it's the only way that actually works using external forms for editing and adding rows, as the events do not fire as expected, also if I disable the addnewrows and the dataset has only one row the update does not fire on cell_leave or cellendedit at all, and I have to save the changes on an button event, bloody microsoft expect us to use this crap, it diffinatley does not work like it should I have also searched high and low for documentation in the SDK on how to implement a real world working example of the DataGridView that vaildates user input on editing and adding new rows. with no matter how many rows you have or what keystrokes you use to leave a cell and then actually send the update to your database using typed datasets.
-
Ok have a simple datagridview well at Least I thought so.... its bound to a typed dataset, it does not do what its supposed to do, when I edit a cell in the row just above the new row line at the bottom and hit ENTER it creates a new bloody row but not really it only actualy creates the new row if I type something, I only wanted to edit the cell I was just in, but now eveytime I change a cell and hit enter it tries to validate the new row with no input in it after it has updated the database, how the hell do you get arroud this, also previuosly, one of my other problems was I would edit a cell and then on CellEndEdit I wanted it to update the database but it would not really run the update I stepped through the code and could see the data in the cell had changed and the tableadapter.update had run but no change to the DB at All, until I edited another cell. Please if any of you know what is goig on with the first problem of createing a new row on hitting enter in a non new row please assist. Thanks
Private Sub TRecieptsTableBindingSource_ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles **TRecieptsTableBindingSource.ListChanged** If Me.StockDB.HasChanges Then Me.UpdatePending = True End If End Sub Private Sub DataGridView1_RowValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) **Handles DataGridView1.RowValidated** If UpdatePending And ValidRow = True Then Me.TRecieptsTableTableAdapter.Update(Me.StockDB.tRecieptsTable) Me.UpdatePending = False ValidRow = False End If End Sub
Set
AllowUserToAddRows
property as false and add a row through code whenever required."If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
-
Set
AllowUserToAddRows
property as false and add a row through code whenever required."If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
Thanks but I have tried this and it causes another problem if there is only one row in the dataset and you try to edit a cell in that row it does not update the database with the new cell value when you leave the cell as soon as there is a second row it works fine. Any thoughts?
-
Yeah I reckon it's the only way that actually works using external forms for editing and adding rows, as the events do not fire as expected, also if I disable the addnewrows and the dataset has only one row the update does not fire on cell_leave or cellendedit at all, and I have to save the changes on an button event, bloody microsoft expect us to use this crap, it diffinatley does not work like it should I have also searched high and low for documentation in the SDK on how to implement a real world working example of the DataGridView that vaildates user input on editing and adding new rows. with no matter how many rows you have or what keystrokes you use to leave a cell and then actually send the update to your database using typed datasets.
Well actually I never use typed datasets either :-O. I'm afraid I like to manage all the processes myself and am happy to pay the penalty with the additional code to achieve the level of control I require. All the wizards in MS will never get me to use their built in data tools, they just suck X| can I be more emphatic, nah! kid sister steps in.
Never underestimate the power of human stupidity RAH