|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Forms and LabelsI am new to Famework Programming and I need your help. In Visual C++ .NET Forms. Labels. If I want to add XXXX to the label, I can do that through the "Text" property in the property editor. But I want to add the XXXX during run time. In other words I want the label to be written during run time. void InitializeComponent(void) { // // label2 // this->label2->Location = System::Drawing::Point(32,16); this->label2->Name = S"label2"; this->label2->Size = System::Drawing::Size(208, 23); this->label2->TabIndex = 6; this->label2->Text = S"XXXX"; } On Mon, 16 Apr 2007 19:56:52 -0700, Allen Maki <allenm***@sbcglobal.net>
wrote: > If I want to add XXXX to the label, I can do that through the "Text" You just set it the same way the InitializeComponent() function sets it. > property in the property editor. But I want to add the XXXX during run > time. In other words I want the label to be written during run time. Assign a string to the "Text" property, in code, just like you see in InitializeComponent(). Thanks Peter,
But, how am I going to assign a string to the "Text" property Show quote "Peter Duniho" <NpOeStPe***@nnowslpianmk.com> wrote in message news:op.tqwqs3a28jd0ej@petes-computer.local... > On Mon, 16 Apr 2007 19:56:52 -0700, Allen Maki <allenm***@sbcglobal.net> > wrote: > >> If I want to add XXXX to the label, I can do that through the "Text" >> property in the property editor. But I want to add the XXXX during run >> time. In other words I want the label to be written during run time. > > You just set it the same way the InitializeComponent() function sets it. > Assign a string to the "Text" property, in code, just like you see in > InitializeComponent(). On Mon, 16 Apr 2007 20:45:57 -0700, Allen Maki <allenm***@sbcglobal.net>
wrote: > But, how am I going to assign a string to the "Text" property Look at the code you posted, or in the InitializeComponent() function in your editor. The example you need is in there. Hi Peter,
At First I would like to thank you for trying to help me. I think I did not make myself clear. I would like to give this example. May be I will become clearer. Suppose I want the time to be stamped at the label and I want to use the following code: System::Console::WriteLine(System::DateTime::Now.ToString("T")); How am I going to use that code? Notice, I give you the current time example, because time can only be given during run time. Show quote "Peter Duniho" <NpOeStPe***@nnowslpianmk.com> wrote in message news:op.tqwvx9s08jd0ej@petes-computer.local... > On Mon, 16 Apr 2007 20:45:57 -0700, Allen Maki <allenm***@sbcglobal.net> > wrote: > >> But, how am I going to assign a string to the "Text" property > > Look at the code you posted, or in the InitializeComponent() function in > your editor. The example you need is in there. On Tue, 17 Apr 2007 00:56:52 -0700, Allen Maki <allenm***@sbcglobal.net>=
= wrote: > Suppose I want the time to be stamped at the label and I want to use t= this->label2->Text =3D System::DateTime::Now.ToString("T");he > following code: > > System::Console::WriteLine(System::DateTime::Now.ToString("T")); > > How am I going to use that code? Note that this is exactly the same as the code that initializes the = property, except you use the string returned by the ToString() method = rather than a hard-coded one. The code that initializes the property isn't any different from "run-tim= e" = code (it is in fact run-time code as well), except that the constant = inserted into the code by the designer is set by you using the designer.= Pete Thanks.
It is very helpful! "Peter Duniho" <NpOeStPe***@nnowslpianmk.com> wrote in message On Tue, 17 Apr 2007 00:56:52 -0700, Allen Maki <allenm***@sbcglobal.net>news:op.tqxslrr78jd0ej@petes-computer.local... wrote: > Suppose I want the time to be stamped at the label and I want to use the this->label2->Text = System::DateTime::Now.ToString("T");> following code: > > System::Console::WriteLine(System::DateTime::Now.ToString("T")); > > How am I going to use that code? Note that this is exactly the same as the code that initializes the property, except you use the string returned by the ToString() method rather than a hard-coded one. The code that initializes the property isn't any different from "run-time" code (it is in fact run-time code as well), except that the constant inserted into the code by the designer is set by you using the designer. Pete |
|||||||||||||||||||||||