Display current time as Label control text
-
I'm almost brand new to C++ so I'm hoping someone can help me out. I'm creating a Windows Form application, and I want to display the current time in place of some static text I was using as one of my Label controls. I've spent some time poking around and I think I'm missing something basic. I was trying something like this: this->label1->Text = System::DateTime::Now; and something a little more complexe like this: this->label1->Text = (System::DateTime::Now.ToString("T")); But no matter how I manipulate the line, either the code editor or the design editor within Visual Basic Studio barks at me. So can someone help me out here and let me know what I'm missing? My goal is to just have something like "5:11:45 PM" show as my Label control when the form is displayed. Thanks!
-
I'm almost brand new to C++ so I'm hoping someone can help me out. I'm creating a Windows Form application, and I want to display the current time in place of some static text I was using as one of my Label controls. I've spent some time poking around and I think I'm missing something basic. I was trying something like this: this->label1->Text = System::DateTime::Now; and something a little more complexe like this: this->label1->Text = (System::DateTime::Now.ToString("T")); But no matter how I manipulate the line, either the code editor or the design editor within Visual Basic Studio barks at me. So can someone help me out here and let me know what I'm missing? My goal is to just have something like "5:11:45 PM" show as my Label control when the form is displayed. Thanks!
Doesn't a label control have member Caption rather than Text ?
-
I'm almost brand new to C++ so I'm hoping someone can help me out. I'm creating a Windows Form application, and I want to display the current time in place of some static text I was using as one of my Label controls. I've spent some time poking around and I think I'm missing something basic. I was trying something like this: this->label1->Text = System::DateTime::Now; and something a little more complexe like this: this->label1->Text = (System::DateTime::Now.ToString("T")); But no matter how I manipulate the line, either the code editor or the design editor within Visual Basic Studio barks at me. So can someone help me out here and let me know what I'm missing? My goal is to just have something like "5:11:45 PM" show as my Label control when the form is displayed. Thanks!
Hi Lucidation, I think, u are now in the wrong place.:confused:
-
Doesn't a label control have member Caption rather than Text ?
I believe the original post is using Windows Forms in which the label control has Text property instead of Caption property.
-
I'm almost brand new to C++ so I'm hoping someone can help me out. I'm creating a Windows Form application, and I want to display the current time in place of some static text I was using as one of my Label controls. I've spent some time poking around and I think I'm missing something basic. I was trying something like this: this->label1->Text = System::DateTime::Now; and something a little more complexe like this: this->label1->Text = (System::DateTime::Now.ToString("T")); But no matter how I manipulate the line, either the code editor or the design editor within Visual Basic Studio barks at me. So can someone help me out here and let me know what I'm missing? My goal is to just have something like "5:11:45 PM" show as my Label control when the form is displayed. Thanks!
You mentioned "Visual Basic Studio", but your code seems to be C++. What was the message that the "code editor" or the "design editor" showed? Please provide the message here so we can have a better understanding of the problem.
-
You mentioned "Visual Basic Studio", but your code seems to be C++. What was the message that the "code editor" or the "design editor" showed? Please provide the message here so we can have a better understanding of the problem.
-
I posted my question in the other forum (adding some additional info as suggested). Thanks!