Solved

VB 2008 - Validate datagridview DATE entry

Posted on 2009-07-04
6
496 Views
Last Modified: 2012-05-07
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
Comment
Question by:ljcor
  • 3
  • 2
6 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24776465
How are you populating the DataGridView?

Wayne
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 24776469
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
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24776475
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:meispisces
ID: 24776600
Whats cell validating? Could you please explain to us


thanks
0
 

Author Comment

by:ljcor
ID: 24776883
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
 

Author Closing Comment

by:ljcor
ID: 31599745
Thanks much, Wayne
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question