Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. DataGridView HELL!!! what am I doing wrong

DataGridView HELL!!! what am I doing wrong

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestionannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GDMFSOB
    wrote on last edited by
    #1

    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

    M D 2 Replies Last reply
    0
    • G GDMFSOB

      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

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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

      G 1 Reply Last reply
      0
      • M Mycroft Holmes

        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

        G Offline
        G Offline
        GDMFSOB
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • G GDMFSOB

          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

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          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

          G 1 Reply Last reply
          0
          • D dan sh

            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

            G Offline
            G Offline
            GDMFSOB
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • G GDMFSOB

              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.

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups