I have a Textbox mask when I enter the data 02/22/2019 and save to the datagrid the grid shows the correct format but the mask textbox shows 22/22/019. It's deleting the leading 0. Data source is Access database and it is set to date time. What is the issue? I have also tried it in code but still get the same results.
Results saved in Grid and database = 02/22/2019
When I select the grid row it shows in the mask textbox as 22/22/019, missing the 0.
Any help
What I have tried:
private void Form1_Load_1(object sender, EventArgs e)
{
maskedTextBox1.Mask = "00/00/0000";
maskedTextBox1.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox1_MaskInputRejected);
maskedTextBox1.KeyDown += new KeyEventHandler(maskedTextBox1_KeyDown);
}
void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
if (maskedTextBox1.MaskFull)
{
toolTip1.ToolTipTitle = "Input Rejected - Too Much Data";
toolTip1.Show("You cannot enter any more data into the date field. Delete some characters in order to insert more data.", maskedTextBox1, 0, -20, 5000);
}
else if (e.Position == maskedTextBox1.Mask.Length)
{
toolTip1.ToolTipTitle = "Input Rejected - End of Field";
toolTip1.Show("You cannot add extra characters to the end of this date field.", maskedTextBox1, 0, -20, 5000);
}
else
{
toolTip1.ToolTipTitle = "Input Rejected";
toolTip1.Show("You can only add numeric characters (0-9) into this date field.", maskedTextBox1, 0, -20, 5000);
}
}