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

  • SEARCH
  • Home
  • 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 8006465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:31:27+00:00 2026-06-04T17:31:27+00:00

I have looked around quite a bit, and nothing seems to answer my question

  • 0

I have looked around quite a bit, and nothing seems to answer my question in particular. I have DataGridView in which I add rows and columns dependent on a certain record count of geospatial data that is held in ArcGIS. The data is then passed through to the gridview for editing.

So I do not use any databinding methods, rather it is a very manual process. I store data into a two-dimensional arrays, which indexes are based off of those certain data record counts.

After the loops are complete, the data should be stored in each cell dependent on index. The very last row that was populated is populated perfectly, yet the other 72 (or so) rows are blank.

Here is the code as follows:

This populates column headers (works great):

For i_FieldNum = 0 To pFields_1.FieldCount - 1

        str_FieldName = UCase(pFields_1.Field(i_FieldNum).Name)
        str_FieldAliasName = pFields_1.Field(i_FieldNum).AliasName

        ReDim Preserve m_array_str_FieldNames(i_FieldNum)
        ReDim Preserve m_array_str_FieldAliasNames(i_FieldNum)
        m_array_str_FieldNames(i_FieldNum) = str_FieldName
        m_array_str_FieldAliasNames(i_FieldNum) = str_FieldAliasName

        i_FieldCount = i_FieldCount + 1
        i_ColNum = i_FieldCount - 1

        'If this is the "SHAPE", "FID", or "OBJECTID" field, remember it:
        If (str_FieldName = "SHAPE") Then
            m_i_FieldNum_Shape = i_FieldCount - 1
        ElseIf (str_FieldName = "FID") Then
            m_i_FieldNum_FID = i_FieldCount - 1
        ElseIf (str_FieldName = "OBJECTID") Then
            m_i_FieldNum_OBJECTID = i_FieldCount - 1
        End If

        'Store the field name in the top row:
        grid_Data.ColumnCount = i_FieldCount
        grid_Data.Columns.Item(i_ColNum).HeaderText = str_FieldName

        ReDim Preserve m_array_l_FieldColLengths(i_ColNum)
        m_array_l_FieldColLengths(i_ColNum) = pFields_1.Field(i_FieldNum).Length

    Next i_FieldNum

This populates the two-dimensional array:

 Do Until pFeat_1 Is Nothing
        'Until we run out of features ...

        i_FeatCount = i_FeatCount + 1


        For i_FieldNum = 0 To pFields_1.FieldCount - 1

        'If the field is recorded as a shape
            If (i_FieldNum = m_i_FieldNum_Shape) Then
                array_Data(i_FeatCount - 1, i_FieldNum) = "<Shape>"
            Else

        'If the value of the field is null
                If IsNothing(pFeat_1.Value(i_FieldNum)) Or pFeat_1.Value(i_FieldNum).ToString = "" Then
                    array_Data(i_FeatCount - 1, i_FieldNum) = "<Null>"
                Else

                    array_Data(i_FeatCount - 1, i_FieldNum) = pFeat_1.Value(i_FieldNum).ToString
                End If
            End If

        Next i_FieldNum

        'End If

        'Move to the next feature (if any).
        pFeat_1 = pFeatCursor_1.NextFeature


    Loop

This is suppose to display the data:

 For i_RowNum = 0 To i_FeatCount - 1

        'Add a new row to the grid:
        grid_Data.RowCount = i_RowNum + 2

        For i_ColNum = 0 To pFields_1.FieldCount - 1

            grid_Data.Item(i_ColNum, i_RowNum + 1).Value = array_Data(i_RowNum, i_ColNum)

        Next i_ColNum

    Next i_RowNum

Everything runs and compiles perfectly, although as I stated before, only the last row’s data is shown (which is populated properly).

If anyone can help figure out why only one row is populated, it would be more than appreciated.

Thank You,

Logan

  • 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-06-04T17:31:28+00:00Added an answer on June 4, 2026 at 5:31 pm

    Check your updated section –This is suppose to display the data: If you data is correctly set then as per my guess it making grid to show wrong data. Modify it as per your columns in your grid that you have added. Or you can create column names string array to put data in particular cells. as dgvr.Cells(columnsArray[index]).Value = array[,]

    For i_RowNum = 0 To i_FeatCount - 1
    
            'Add a new row to the grid:
            DataGridViewRow dgvr = new System.Windows.Forms.DataGridViewRow();
            dgvr.CreateCells(grid_Data)
    
            For i_ColNum = 0 To pFields_1.FieldCount - 1
                dgvr.Cells(i_ColNum).Value = array_Data(i_RowNum, i_ColNum)
            Next i_ColNum
            grid_Data.Rows.Add(dgvr)
    Next i_RowNum
    

    Ref: Adding a New Row to DataGridView and How to: Manipulate
    Rows in the Windows Forms DataGridView Control

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

Sidebar

Related Questions

I have looked around on Google and StackOverflow for the answer to this question,
I have looked around quite a bit and can't seem to get working a
I have looked around for quite some time trying to get openCV installed. I'm
I have looked around here and the Internet in general but it seems this
I've looked around on stack overflow for days and have not seen an answer
I looked around but haven't found an answer to this. I have a CentOS
Hey guys, looked around but couldn't quite get an answer or figure it myself.
I have looked around but cannot seem to find anything quite like i need.
I have looked around for an answer and came up with this code. I
I have looked around but I haven't really found an answer that seals the

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.