Click here to Skip to main content
16,022,536 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to complete TextBox with date(dd/mm/yyyy), however, I want to entering only dd/mm without year, can I change it or not. if so, could you help me please?


What I have tried:

I want to complete TextBox with date(dd/mm/yyyy), however, I want to entering only dd/mm without year, can I change it or not. if so, could you help me please?
Posted
Updated 21-Sep-20 22:56pm

Thanks I solved my problem with this code
Textbox.Text = Textbox.Text + "/" + DateTime.Now.Year;

Also, Thanks to Mr.OriginalGriff for the comment
 
Share this answer
 
Well ... just add "/yyyy" to the text when you user exits the TB - it has a LostFocus event which tells you that.
But which year? And is the dd/mm part correct and valid?

I'd strongly recommend you use a DateTimePicker control instead of a TextBox as it provides an "always valid" DateTime value directly.
 
Share this answer
 

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