Solved

VB 2008 - Validate datagridview DATE entry

Posted on 2009-07-04
6
490 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now