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. Managed C++/CLI
  4. Dynamic label text?

Dynamic label text?

Scheduled Pinned Locked Moved Managed C++/CLI
c++graphicshelptutorialquestion
2 Posts 2 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

    Well, I'm new to C++ and I think I'm missing something obvious. I'm trying to create a text label control on a form, but I want the actual text to be dynamic (I want to use a variable that I can change on-the-fly). So where I'd normally have something like this: this->labelDynamicText->Name = L"labelDynamicText"; this->labelDynamicText->Size = System::Drawing::Size(145, 34); this->labelDynamicText->TabIndex = 5; this->labelDynamicText->Text = L"This is some dynamic text"; I was thinking of something like this: this->labelDynamicText->Name = L"labelDynamicText"; this->labelDynamicText->Size = System::Drawing::Size(145, 34); this->labelDynamicText->TabIndex = 5; this->labelDynamicText->Text = MyDynamicText; and I'd be able to something like: int intCount = 0 Do Until [intCount = 60] MyDynamicText = "this text sits on the screen for a few seconds" intCount = intCount + 1 Loop MyDynamicText = "this text displays after 60 seconds" So can anyone help guide me in the right direction? Can I easily do this, and where do I start? Thanks in advance!

    L 1 Reply Last reply
    0
    • L Lucidation

      Well, I'm new to C++ and I think I'm missing something obvious. I'm trying to create a text label control on a form, but I want the actual text to be dynamic (I want to use a variable that I can change on-the-fly). So where I'd normally have something like this: this->labelDynamicText->Name = L"labelDynamicText"; this->labelDynamicText->Size = System::Drawing::Size(145, 34); this->labelDynamicText->TabIndex = 5; this->labelDynamicText->Text = L"This is some dynamic text"; I was thinking of something like this: this->labelDynamicText->Name = L"labelDynamicText"; this->labelDynamicText->Size = System::Drawing::Size(145, 34); this->labelDynamicText->TabIndex = 5; this->labelDynamicText->Text = MyDynamicText; and I'd be able to something like: int intCount = 0 Do Until [intCount = 60] MyDynamicText = "this text sits on the screen for a few seconds" intCount = intCount + 1 Loop MyDynamicText = "this text displays after 60 seconds" So can anyone help guide me in the right direction? Can I easily do this, and where do I start? Thanks in advance!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Off topic: Please use <pre></pre> tags around your code (use the code block button above) rather than bolding. On topic : Changing the contents of your MyDynamicText variable does not force it to refresh the label on your form. You also need to resend it to this->labelDynamicText->Text as was done in the initialisation. Note also that your counter will run very fast rather than taking 60 seconds, you probably need to use a timer or sleep() call.

      It's time for a new signature.

      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