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. DataGridView, RowEnter exception upon header select

DataGridView, RowEnter exception upon header select

Scheduled Pinned Locked Moved C#
cssdatabasequestion
2 Posts 1 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.
  • L Offline
    L Offline
    Lodeclaw
    wrote on last edited by
    #1

    I'm filling a datagridview with rows of data and upon selection (RowEnter event) of a full row the primary key is copied into a textbox which is then used as a foreign key in another table and gives me the quantity of rows containing the foreign key. This is fine and dandy, except when I click on the DataGridView headers it throws an exception:

    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Any ideas as to why this is occurring? Thanks in advance!

    L 1 Reply Last reply
    0
    • L Lodeclaw

      I'm filling a datagridview with rows of data and upon selection (RowEnter event) of a full row the primary key is copied into a textbox which is then used as a foreign key in another table and gives me the quantity of rows containing the foreign key. This is fine and dandy, except when I click on the DataGridView headers it throws an exception:

      Index was out of range. Must be non-negative and less than the size of the collection.
      Parameter name: index

      Any ideas as to why this is occurring? Thanks in advance!

      L Offline
      L Offline
      Lodeclaw
      wrote on last edited by
      #2

      Well, I got around the issue with a try/catch block. Out of curiosity, however, I'd love to know if there are other alternatives to this. :doh:

      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