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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:32:22+00:00 2026-06-13T22:32:22+00:00

I have a DataGridView control on my form. It has 6 columns and 6

  • 0

I have a DataGridView control on my form. It has 6 columns and 6 rows (which will never change). When a user enters data in a cell under any column, I want to make sure they fill in the rest of the cells for that row. So basically if they put data in row 0 – column 0, I want to ensure that row 0 – column 1, row 0 – column 2 and so on… have data in them. I need this for validation reasons before this will be committed to the database. If the fields are not all filled in for that row, I want to display a message containing the rows that need to be fixed.

Any help is greatly appreciated!

Here’s an update, I have figured out what needed to be done.

Private Sub ValidateYear()

    Dim oInvYear As New Collection
    Dim oErrorMsg As New System.Text.StringBuilder
    Dim blnErrFound As Boolean = False

    'Loop through year column and check for number, if blank skip'
    For i As Integer = 0 To dgvIntervals.Rows.Count - 1
        If Not String.IsNullOrEmpty(dgvIntervals.Rows(i).Cells(4).Value) Then
            If Not IsNumeric(dgvIntervals.Rows(i).Cells(4).Value) Then
                oInvYear.Add(i + 1)
                blnErrFound = True
            End If
        End If
    Next

    'If errors found, lets append them to our message'
    If blnErrFound Then
        oErrorMsg.Append("PLEASE FIX ERRORS BELOW BEFORE PROCEEDING")
        oErrorMsg.AppendLine("")
        oErrorMsg.Append(vbCrLf)

    'Get our year count errors'
    If oInvYear.Count > 0 Then
        oErrorMsg.Append("* Year must be a number- ")
        oErrorMsg.Append("Line(s): ")
        For i As Integer = 1 To oInvYear.Count
            If i >= 2 Then
                oErrorMsg.Append(", ")
            End If
            oErrorMsg.Append(oInvYear.Item(i).ToString)
        Next
        oErrorMsg.Append(vbCrLf)
    End If

    'Show them to our user'
    MsgBox(oErrorMsg.ToString)

End Sub 
  • 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-13T22:32:23+00:00Added an answer on June 13, 2026 at 10:32 pm

    Use the CellValidating or RowValidating events of the DataGridView control to validate the data that has been entered by the user.

    Private Sub OnRowValidating(ByVal sender As Object, ByVal args As DataGridViewCellCancelEventArgs) Handles DataGridView1.RowValidating
      Dim row As DataGridViewRow = DataGridView1.Rows(args.RowIndex)
      For Each cell As DataGridViewCell In row.Cells
         If String.IsNullOrEmpty(cell.Value.ToString()) Then
            'show a message box or whatever...
         End If
      Next
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView in a form that has a data table as the
I have a windows form where I am using DataGridView control. It is bind
I have a DataGridView control with two columns. The default color of the text
I have a control which extends the DataGridView control. I am overriding the ProcessDialyKey
I have a windows form with a DataGridView control. I bound it into an
I have a TableLayoutPanel that contains rows of labels. This control lives on form
I have a DatagridView control on a Windows form. It's selectionMode property is set
I have a form with a datagridview control on it. The datagridview is bound
i have a DataGridView on the Form. I select some data from database and
I have a mydatagridview class which inherits from the built-in DataGridView control, as shown

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.