Click here to Skip to main content
15,921,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way where I can autofill date like I have two columns in gridview both the columns are dateformat(MM/dd/yyyy) now if in column effective date I entered 12/01/2020 and than next column Expiry date should show populate 1 year greather than previous year as 12/01/2021...I am using it winform ,is there any reference or can help me to write this in code please. I am not getting while searching in google.Please help me .

What I have tried:

I have not tried anything as I am blank how to write
Updated 16-Jun-22 19:55pm

Share this answer
I'd probably do it at the source level: when you retrieve the data to enter, generate the "extra data" then.
For example, if your data comes from SQL:
SELECT MyDateColumn, DATEADD(yy, 1, MyDateColumn) AS OneYearOn FROM MyTable
Would give you the two columns you need.
Similarly, when you get the DataGridView.CellEndEdit Event[^] for the date column, generate the new column value and set that in the data.
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