Click here to Skip to main content
12,512,548 members (71,864 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
I use Visual studio 2005 and SqlServer 2000
I have a data grid view name as h_card
4 columns in that grid view named as



Number
year
dob
gender



Is there any way to make the year and dob column as of date time picker type IN VISUAL STUDIO 2005.

or

How can i validate only these two columns to take the value like
"MM/DD/YYYY"
Posted 9-Jan-13 16:46pm
ankur7891.5K
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this out

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    DateTimePicker1.Format = DateTimePickerFormat.Custom
    DateTimePicker1.CustomFormat = "MM/dd/yyyy"
End Sub
  Permalink  
Comments
AnkurGupta OM 9-Jan-13 23:18pm
   
Sir
these
year and dob is in datagridview and i used vb.net


is there any way to put date time picker in the datagrid view coloumn.
or
i want to make validation that these columns in the data grid view not take any other value except of type "MM/DD/YYYY"
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

dataGridView1.CellBeginEdit += CellBeginEdit;
 
private void CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
    DataGridView dgv = (DataGridView)sender;
    if (dgv[0, e.RowIndex].Value == "2") # or whatever conditions you want to check
    {
        e.Cancel = true;
    }
    else
    {
        e.Cancel = false;
    }
}
  Permalink  
Comments
AnkurGupta OM 9-Jan-13 23:18pm
   
Sir
these
year and dob is in datagridview and i used vb.net


is there any way to put date time picker in the datagrid view coloumn.
or
i want to make validation that these columns in the data grid view not take any other value except of type "MM/DD/YYYY"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100