Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Display current time as Label control text

Display current time as Label control text

Scheduled Pinned Locked Moved C / C++ / MFC
c++designhelpquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lucidation
    wrote on last edited by
    #1

    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!

    P B L 3 Replies Last reply
    0
    • L Lucidation

      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!

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      Doesn't a label control have member Caption rather than Text ?

      L 1 Reply Last reply
      0
      • L Lucidation

        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!

        B Offline
        B Offline
        BIJU Manjeri
        wrote on last edited by
        #3

        Hi Lucidation, I think, u are now in the wrong place.:confused:

        1 Reply Last reply
        0
        • P Peter_in_2780

          Doesn't a label control have member Caption rather than Text ?

          L Offline
          L Offline
          loyal ginger
          wrote on last edited by
          #4

          I believe the original post is using Windows Forms in which the label control has Text property instead of Caption property.

          1 Reply Last reply
          0
          • L Lucidation

            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!

            L Offline
            L Offline
            loyal ginger
            wrote on last edited by
            #5

            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.

            C 1 Reply Last reply
            0
            • L loyal ginger

              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.

              C Offline
              C Offline
              Cool_Dev
              wrote on last edited by
              #6

              ask this question in Managed C++/CLI forums

              L 1 Reply Last reply
              0
              • C Cool_Dev

                ask this question in Managed C++/CLI forums

                L Offline
                L Offline
                Lucidation
                wrote on last edited by
                #7

                I posted my question in the other forum (adding some additional info as suggested). Thanks!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups