Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

VB 2008 - Validate datagridview DATE entry

User is allowed to use long or short date entry method for a Datagridview field.  The entry has to pass CellValidating.

I do not know how to test for a valid date entry.  User can enter long or short date - but it has to be valid.
0
ljcor
Asked:
ljcor
  • 3
  • 2
1 Solution
 
Wayne Taylor (webtubbs)Commented:
How are you populating the DataGridView?

Wayne
0
 
Wayne Taylor (webtubbs)Commented:
If you are setting the DataSource, if the DataType of your date column is Date, a message will inform the user of an incorrect date format.

See the below example.


Wayne
Public Class Form1 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
        Dim dt As New DataTable
        dt.Columns.Add("Number")
        dt.Columns.Add("Date", GetType(Date)) 
        DataGridView1.DataSource = dt 
    End Sub 
    Private Sub DataGridView1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
        MsgBox(e.Exception.Message)
    End Sub 
End Class

Open in new window

0
 
Wayne Taylor (webtubbs)Commented:
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
meispiscesCommented:
Whats cell validating? Could you please explain to us


thanks
0
 
ljcorAuthor Commented:
Sorry I disappeared: this Southern California guy posted the question and then fell asleep.  Very sorry.

The grid is being populated by user data entry.

"cell validating" is the use of the Datagrid1_CellValidating event.
 
My question now: at what point in the sequence is the CellParsing event called?  Before or after the CellValidating event?
0
 
ljcorAuthor Commented:
Thanks much, Wayne
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now