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. C#
  4. Problem when closing Form containing DataGridView

Problem when closing Form containing DataGridView

Scheduled Pinned Locked Moved C#
csharpdatabasehelpvisual-studio
3 Posts 2 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.
  • K Offline
    K Offline
    kbalias
    wrote on last edited by
    #1

    Hi I have a very strange problem. I am using Visual Studio 2005 and C# to develop a Windows application. My database is a MS Access 2003 database. On my Form I have a DataGridView that is bound to a table in the database. There are also a few DataGridViewComboBoxColumns that are bound to different lookup tables in the database. I specify the BindingSources for all of these using the designer. When I run the app the DataGridView is populated as expected. The DataGridViewComboBoxes also work fine and I can change the values. The database is also updated correctly. So everything seemed fine. Then I added a Button control to the form by dragging a Button control from the Toolbox onto the Form. Before I added any further code I ran the app again to check something. This time I encountered a problem. After I clicked the Close button in the Controlbox (Top right on the form) the DataGridView gets cleared of data row by row and when all the rows have been cleared the following message appears: "Index 0 does not have a value.". I just cannot see the relationship between just adding a Button to the form and this error message. I am stumped and any advice will be appreciated. Regards. Kobus

    realJSOPR 1 Reply Last reply
    0
    • K kbalias

      Hi I have a very strange problem. I am using Visual Studio 2005 and C# to develop a Windows application. My database is a MS Access 2003 database. On my Form I have a DataGridView that is bound to a table in the database. There are also a few DataGridViewComboBoxColumns that are bound to different lookup tables in the database. I specify the BindingSources for all of these using the designer. When I run the app the DataGridView is populated as expected. The DataGridViewComboBoxes also work fine and I can change the values. The database is also updated correctly. So everything seemed fine. Then I added a Button control to the form by dragging a Button control from the Toolbox onto the Form. Before I added any further code I ran the app again to check something. This time I encountered a problem. After I clicked the Close button in the Controlbox (Top right on the form) the DataGridView gets cleared of data row by row and when all the rows have been cleared the following message appears: "Index 0 does not have a value.". I just cannot see the relationship between just adding a Button to the form and this error message. I am stumped and any advice will be appreciated. Regards. Kobus

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #2

      It seems pretty obvious that you're trying to delete one more row than the grid has. Try using the debugger - I know, that might seem too much like being a programmer, but after the first few times, you'll find the debugger to be pretty damn useful.

      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

      K 1 Reply Last reply
      0
      • realJSOPR realJSOP

        It seems pretty obvious that you're trying to delete one more row than the grid has. Try using the debugger - I know, that might seem too much like being a programmer, but after the first few times, you'll find the debugger to be pretty damn useful.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        K Offline
        K Offline
        kbalias
        wrote on last edited by
        #3

        Thanks for the reply. What baffles me is that I have not made any changes. I have not added new records, or modified records. or deleted any rows. I run the app and immediately closes it and the error comes up. Kobus

        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