This topic is now archived and is closed to further replies.

Label won't show, problem inside the form class?

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am new to this whole new forms in Windows, so i''ll be having plenty and plenty and plenty of questions for all you experts as the minutes and hours go on. But at the moment, my current question is why don''t my labels show up but my buttons do? Anyone have any suggestions?
#include "stdafx.h"

#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::Windows::Forms; 
using namespace System::Drawing;

__gc public class CppForm : public Form {
	Text = S"Test Form";
	FormBorderStyle = FormBorderStyle::Fixed3D;
///////	BEGIN BUTTON CONTROLS////////////
	Button* btn1;
	Button* btn2;
	void Setup_Buttons()
	btn1 = new Button();
	btn1->Text = S"OK";
	btn1->Size = System::Drawing::Size(70,25);
	btn1->Location = Point(130,225);
	btn1->Click += new EventHandler(this,&CppForm::Btn1_Clicked);

	btn2 = new Button();
	btn2->Text = S"Cancel";
	btn2->Size = System::Drawing::Size(70,25);
	btn2->Location = Point(210,225);
	btn2->Click += new EventHandler(this,&CppForm::Btn2_Clicked);

void  Btn1_Clicked(Object* pSender, EventArgs* pArgs)
	MessageBox::Show(S"It worked!", S"Message...");
void  Btn2_Clicked(Object* pSender, EventArgs* pArgs)
	MessageBox::Show(S"This Works too!", S"Message...");
///////BEGIN LABEL CONTROLS//////////////////
Label* theLabel;
void Setup_Label()
	theLabel = new Label();
	theLabel->AutoSize = true;

	theLabel->Text = S"  Acme Consulting, Inc.";
	theLabel->Font = new System::Drawing::Font(S"Verdana", 16, FontStyle::Italic);
	theLabel->ForeColor = Color::Black;

	theLabel->Location = Point(20,20);
	theLabel->Size = System::Drawing::Size(theLabel->PreferredWidth, theLabel->PreferredHeight);

int main()
    Console::WriteLine(S"Forms Example");
	Application::Run(new CppForm());
	return 0;

Share this post

Link to post
Share on other sites