Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

Try this out

VB
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
 
Share this answer
 
Comments
ankur789 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"
C#
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;
    }
}
 
Share this answer
 
Comments
ankur789 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"
[no name] 9-Jan-13 23:34pm    
okk i will give u update for vb.net purposes later..

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900