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 7864453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:47:40+00:00 2026-06-02T23:47:40+00:00

VB.NET 4.0 framework Windows Forms Application. So I have a DataGridView that I have

  • 0

VB.NET 4.0 framework Windows Forms Application. So I have a DataGridView that I have dropped on my form in designer, set all the columns to readOnly, AllowUserToAddRows = False, AllowUserToDeleteRows = False. Now for the part where it the code is going bad at.

My function Looks Like this:

    Private Sub fill_items()
    Dim prop As List(Of property_info) = db.property_info.ToList
    Dim units As List(Of unit) = db.units.ToList
    Dim _year As Integer = System.DateTime.Now.Year
    Dim fin As List(Of financial) = db.financials.Where(Function(f) f.Year_start.Value.Year = _year).OrderBy(Function(f) f.transaction_date).ToList

    Dim x As Integer = 0

    For Each _i In prop

        x += 1
        Dim _typeName As String = String.Empty
        Dim i As property_info = _i
        Select Case i.property_type
            Case Is = 0
                _typeName = "Storage"
            Case Is = 1
                _typeName = "House/Apartment"
            Case Is = 2
                _typeName = "Office Space"
        End Select

        reports1GridView.Rows.Add(_typeName, i.property_Name, " ", " ", " ", " ")

        For Each _t In units.Where(Function(f) f.propertyId = i.idProperties)
            Dim t As unit = _t
            x += 1
            For Each trans In fin.Where(Function(F) F.Unit_finId = t.UnitId)
                x += 1
                Dim _ttype As String = String.Empty
                Dim _typeCheck As Integer = 0
                Select Case trans.transaction_type
                    Case Is = 0
                        _ttype = "Payment Recieved"
                        _typeCheck = 0
                    Case Is = 2
                        _ttype = "Rent Charged"
                        _typeCheck = 1
                    Case Is = 3
                        _ttype = "Deposit"
                        _typeCheck = 1
                    Case Is = 20
                        _ttype = "Late Fee"
                        _typeCheck = 0
                    Case Is = 4
                        _ttype = "Auction Collection"
                        _typeCheck = 0
                    Case Is = 5
                        _ttype = "Auction Fee"
                        _typeCheck = 2
                    Case Is = 6
                        _ttype = "City Tax"
                        _typeCheck = 0
                    Case Is = 7
                        _ttype = "County Tax"
                        _typeCheck = 0
                    Case Is = 8
                        _ttype = "State Tax"
                        _typeCheck = 0
                    Case Is = 9
                        _ttype = "Maintenance"
                        _typeCheck = 2
                End Select

                Dim _TypeValue As Decimal = Nothing
                Select Case _typeCheck
                    Case Is = 0
                        _TypeValue = trans.Amount_Paid
                    Case Is = 1
                        _TypeValue = trans.amount_due
                    Case Is = 2
                End Select
                Dim _tDate As Date = trans.transaction_date
                Dim _tDateString As String = _tDate.ToShortDateString.ToString
                reports1GridView.Rows.Add(" ", " ", t.UnitId, _ttype, _tDateString, _TypeValue)

                Dim xl As String = String.Empty
            Next
        Next
    Next
End Sub

My problem is that the datagridview is displaying only values in the 0,1,2,3 columns of the gridview.. The Gridview looks correct until it Gets to column 3 which is where the transaction type goes. For some reason the amount that should be in column 5 is being displayed in that column and columns 4 and 5 are being left completely blank.. I looked at the values contained in the variables in the last reports1GridView.Rows.Add of the function and all of the variables are not only correct but in the correct order. So my question is why is this failing…

  • 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-02T23:47:42+00:00Added an answer on June 2, 2026 at 11:47 pm

    Supposing that your DataGridView is unbound (meaning that no columns are automatically defined) you need to create the appropriate columns required by your code. Then the Row.Add(item, ….) will work

    For example:

    Private Sub SetupGrid()
        reports1GridView.ColumnCount = 5
        reports1GridView.Columns(0).Name = "Type"
        .... ' other columns
    End Sub
    

    before entering in your main loop call this method to define name and type of your columns

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

Sidebar

Related Questions

I have written a Windows Forms application in C#, .NET framework 2.0, that uses
I have encountered a rather nasty problem with the DataGridView control (Windows.Forms, .NET Framework
I have a simple Windows Form application that is using the .net 3.5 compact
I have a Windows Forms application developed using C# in .NET framework 3.5, Service
I have a Windows Forms application built using the .NET 3.5 Framework which self
I've got yet another deployment problem. What I have: little Windows Forms application that
Does .NET framework have a collection of icons for use in Windows Forms or
I have created a setup project with VS2008 for a .NET Windows Forms application
While upgrading a Windows Forms application from the .NET 1.1 framework to the .NET
I've been developing a windows forms application in C# (.net framework 4) and trying

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.