Forms and labels

A

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

}
 
P

pvdg42

Allen Maki said:
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";

}
You don't indicate the issue you're having, but I think I can guess (if
you're using VS 2005).
If you're getting a syntax error on the line:

this->label2->Text = S"XXXX";

that says:

error C3921: Use of S-prefixed strings requires /clr:blush:ldSyntax command line
option

simply remove the "S"

this->label2->Text = "XXXX";
 
P

pvdg42

Allen Maki said:
Hi Everybody,



I am new to Famework Programming and I need your help.



In Visual C++ .NET

Forms.

Labels.
<snip>

Oops!
My first response is inadequate. I now realize that you're trying to create
the label programatically as well as assign a value to the test property.
Using this code, I now see your issue. My label does appear.
private: System::Windows::Forms::Label^ label2;

void InitializeComponent(void)

{

...

this->label2 = (gcnew System::Windows::Forms::Label());

this->SuspendLayout();



this->label2->AutoSize = false;

this->label2->BorderStyle =
System::Windows::Forms::BorderStyle::FixedSingle;

this->label2->Location = System::Drawing::point(95, 151);

this->label2->Name = L"label1";

this->label2->Size = System::Drawing::Size(50, 15);

this->label2->TabIndex = 1;

this->Controls->Add(this->label2);

....

}



Later in an event procedure:

this->label2->Text = "XXXX";



This works fine.
 
A

Allen Maki

Hi pvdg42,

I have here both the of the codes. Can you show how to do the changes ?







this->label2->AutoSize = true;

this->label2->Font = new System::Drawing::Font(S"Verdana", 16,
System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::point,
(System::Byte)0);

this->label2->Image = (__try_cast<System::Drawing::Image *
(resources->GetObject(S"label1.Image")));

this->labe21->ImageAlign = System::Drawing::ContentAlignment::MiddleLeft;

this->label2->Location = System::Drawing::point(8, 112);

this->label2->Name = S"label1";

this->label2->Size = System::Drawing::Size(277, 29);

this->label2->TabIndex = 2;

this->label2->Text = S" Time Tracking System";







private: System::Void label2_Click(System::Object * sender,
System::EventArgs * e)

{

this->label2->Text = S"XXXX";

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top