Home All Groups Group Topic Archive Search About
Author
17 Apr 2007 2:56 AM
Allen Maki
Hi Everybody,



I 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";

}

Author
17 Apr 2007 3:04 AM
Peter Duniho
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().
Author
17 Apr 2007 3:45 AM
Allen Maki
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().
Author
17 Apr 2007 4:55 AM
Peter Duniho
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.
Author
17 Apr 2007 7:56 AM
Allen Maki
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.
Author
17 Apr 2007 4:40 PM
Peter Duniho
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=
he
> following code:
>
> System::Console::WriteLine(System::DateTime::Now.ToString("T"));
>
> How am I going to use that code?

     this->label2->Text =3D System::DateTime::Now.ToString("T");

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
Author
17 Apr 2007 7:38 PM
Allen Maki
Thanks.

It is very helpful!


"Peter Duniho" <NpOeStPe***@nnowslpianmk.com> wrote in message
news:op.tqxslrr78jd0ej@petes-computer.local...
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 the
> following code:
>
> System::Console::WriteLine(System::DateTime::Now.ToString("T"));
>
> How am I going to use that code?

     this->label2->Text = System::DateTime::Now.ToString("T");

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

AddThis Social Bookmark Button