473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Forms and labels

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

}
Apr 17 '07 #1
3 1395

"Allen Maki" <al*******@sbcglobal.netwrote in message
news:KF*******************@newssvr12.news.prodigy. net...
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:oldSyntax command line
option

simply remove the "S"

this->label2->Text = "XXXX";
Apr 17 '07 #2

"Allen Maki" <al*******@sbcglobal.netwrote in message
news:KF*******************@newssvr12.news.prodigy. net...
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.


Apr 17 '07 #3
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";

}





"pvdg42" <pv****@newsgroups.nospamwrote in message
news:um**************@TK2MSFTNGP04.phx.gbl...
>
"Allen Maki" <al*******@sbcglobal.netwrote in message
news:KF*******************@newssvr12.news.prodigy. net...
>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.


Apr 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: koray | last post by:
hi everyone, in my form i have to take some date information in dd-mm-yy format. but i don't want user to use tabs while typing. for example s/he should simply type 280104 but 28/01/04 must...
39
by: Zak McGregor | last post by:
Hi all Are there any good solutions to aligning form field names and input boxes without resorting to tables? I am struggling to do this nicely at the moment. Thanks Ciao Zak
2
by: Nick Cardi | last post by:
I have a very strange issue. I have written a Dot Net application in VB.Net. When the application is run on some laptops the Forms are painted strangely. Labels are much wider then they were when...
2
by: aaj | last post by:
Hi all I have a small but rather annoying problem with continuos forms, and am wondering if anyone can suggest a method of getting over it. The front end is Access 2002 with the BE being SQL...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
5
by: dominique | last post by:
Hi, I want to write code to manage standard (or generic) forms in Windows Forms (i don't know the correct word) like that : - a base form in a class : frmBase with some controls inside it :...
1
by: Neal | last post by:
I need to create many labels to fit on a windows forms and instead of using the designer to create a large number of text labels I just wanted to make an array of them and then loop through them to...
1
by: PaulB | last post by:
In my application, I have many forms. Some of these forms contains some labels, which are placed in the header section, and act as a column header. Because of the available space, the orientation...
8
by: obrienkev | last post by:
Hi all, I have a certain number of labels that I want displayed on each of my Windows Forms in my c# Desktop Application project. Each of the labels is used to open a relavent windows form. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.