Solved

VB 2008 - Validate datagridview DATE entry

Posted on 2009-07-04
6
495 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple file Upload asp.net 2 49
Datagridview column when exported to Excel changes vb.net 1 13
write xml in vb.net 2 24
Winform Module - What is the ASP.Net equiv 2 22
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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 …

809 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