The basics

matt09524

Freshman
Joined
Sep 14, 2005
Messages
47
I am new to C++ and .NET appication developement and have some very basic questions.

1. How do I make a linklabel work? I have seen some templates out there, but they fail to compile... apparently the templates are trying to use a sub class that is not defined and that provides all sorts of compilation failures. Anyone have good code including any classes I need to load up and how to do all that?

2. I've got this form all designed out... How do I make it so that when the button is clicked, the current form changes to the next step in the program? Also, with regards to this, how can I make it so that there is like a "return to beginning" button/link that will take them to the start of the program?

3. ... /duck and how do I get items that I have put in a drop down box to execute when the "GO" button is clicked?

I know this may seem very basic for you guys, but I learn this stuff by asking others questions and this is not related to my career job so I have no one to ask there. If replying, you can also feel free to e-mail me directly at matt09524@hotmail.com. But I think replying here would benefit the next newb :P

* I am using the MS Visual C++ Beta2.
 
Last edited:
In .NET you have event that will do all the thing you want. When you need to catch the button click, or the selected item of a combobox, etc

1) Imagine we have a link label with the name of linkLabel1. If you want to make an action when a user clicks the label you have to include the code of the event of clicking. To include the code automaticly, just go the design mode and double click on the label. If not here is the code

Code:
//Add this line in the void InitializeComponent(void) method
			this->linkLabel1->LinkClicked += new System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, linkLabel1_LinkClicked);

//this should be next to the other MEthdos
private: System::Void linkLabel1_LinkClicked(System::Object *  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs *  e)
		 {
                                //YOUR CODE HERE
		 }



2) Now for your button it's exactly the same. In the design mode just double click on the button to the code be added automaticly. If not just add this code

Code:
//Add this line in the void InitializeComponent(void) method
this->button1->Click += new System::EventHandler(this, button1_Click);

	private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
			 {
                                            //your code here
			 }
To the program return to the beginning you have to have a link label or a botton to do just that

3)I don't fully understand what u mean to execute the items im a dropdown....can u explain betteR?
 
For 3 i think he means, with a drop down list, if you have say, Form2, Form 3 & Form3 as options in it, When you select one of those then click GO it will execute some code to do with that option, Example:

Dropdown:
-Form2
-Form3
-Form4

User selects Form3 and clicks GO
Application executes code for option Form3 which would be something like
Form3.Show
 
Code:
//Add this line in the void InitializeComponent(void) method
			this->linkLabel1->LinkClicked += new System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, linkLabel1_LinkClicked);

//this should be next to the other MEthdos
private: System::Void linkLabel1_LinkClicked(System::Object *  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs *  e)
		 {
                                //YOUR CODE HERE
		 }

"// your code here" what is the code? As I said, I am a complete new to this. I know I need an address in there somewhere, but what is the string?

Code:
//Add this line in the void InitializeComponent(void) method
this->button1->Click += new System::EventHandler(this, button1_Click);

	private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
			 {
                                            //your code here
			 }

Same thing here... what is the code to execute a new form (previously created, but in the same space as the original one?)

To the program return to the beginning you have to have a link label or a botton to do just that

?? Code?

3)I don't fully understand what u mean to execute the items im a dropdown....can u explain betteR?

basically I made a drop down menu... It has 10 items in it. When the drop it down, click on one I need the GO button underneath the drop down to execute the form that I want.

Thanks :)
 
Back
Top