Click here to Skip to main content
15,914,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a label called DateTime in my C# WPF application and I want it to display the Current Day/Month and the time HH:MM:SS

C#
private void DateTime_Loaded(object sender, RoutedEventArgs e)
{
    DateTime.Content = DateTime.Now.ToShortDateString("DD/MM HH:MM:SS");
}


but i get this error
SQL
Label' does not contain a definition for 'Now' and no extension method 'Now' accepting a first argument of type 'Label' could be found (are you missing a using directive or an assembly reference?)
Posted

1 solution

Quote:
I have a label called DateTime



It is a really strange name for a Label! You are using the name of class "DateTime" for a control, don't you see it? You need to re-name your Label (e.g. "myDateTime").
 
Share this answer
 
v5

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