Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 368249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:48:21+00:00 2026-05-12T13:48:21+00:00

I have a DataGridView to which I’ve set a list of objects to the

  • 0

I have a DataGridView to which I’ve set a list of objects to the DataSource. (I’m in VS 2005 using VB.) I created the DataGridView by creating a Data Source of type AssetIdentifier and dragging that Data Source onto my form.

I want to update the DataGridView when the selection in either a combo box or another DataGridView changes. (Below I’m considering a click in another DataGridView.) The following works:

Public Class dlgShowAssets

    ' class member variable

    Private assetIdList As List(Of AssetIdentifier)

    ' pertinent subs and functions

    Private Sub RefreshAssetIdentifierDataGridView()
        AssetIdentifierDataGridView.DataSource = assetIdList
    End Sub

    Private Sub AssetDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles AssetDataGridView.CellClick     
        assetIdList = RepopulateTheList(id)
        Me.RefreshAssetIdentifierDataGridView()
    End Sub

End Class

In this case, I always knew that assetIdList would have at least one element. I’d update the list, and reset the data source of the DataGridView to that list, and all was well.

When I applied this to another situation, for which I couldn’t guarantee that the list would have at least one element, things would work fine as long as I had at least one element in the list, but if the list became empty, the DataGridView threw System.IndexOutOfRangeException a number of times. The rows in the DataGridView would not go away if I went from a non-zero number of elements to zero.

I tried a workaround, which was to remove all of the elements, add one “dummy” element, and then re-bind the list to the control, and it still didn’t work.

Also, following all of those exceptions, I’d get other similar exceptions when I hovered over the cells in the DataGridView.

I’ve been trying to track down this behavior for a few hours. Any insights? Thanks!

Will be happy to add more info if needed.

UPDATE: Some of the members of AssetIdentifier were “Nothing” but I fixed that in the constructor, and the exceptions still occur.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:48:21+00:00Added an answer on May 12, 2026 at 1:48 pm

    Refactored code and it works …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 237k
  • Answers 237k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think the problem is that you declare your parameters… May 13, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer Could you use a common cache object for the last… May 13, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer I went with the implementation that I found on Wikipedia… May 13, 2026 at 6:39 am

Related Questions

I have a DataGridView to which I've set a list of objects to the
I have a DataGridView object to which I've bound a list of objects (of
I have a DataGridView with custom columns. But when I add a DataGridViewComboBoxColumn and
I have a simple VB.NET 2008 app that helps users to edit fields in
It's a pleasure to see how much knowledge people have on here, it's a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.