I am creating a game using windows forms, i need to show the score on all windows. how do i create a global variable so that it can be displayed on every form?
How do i convert a string to an int? I know how to do it for the console but it doesn't seem to work when using windows forms.
Also, if and swtich statements don't seem to work when i use them in windows forms.
Loading
Drew TaylorPosted Oct 13, 2006, 4:28 AM
I still can't get the score to work,
public class Information : Form1I have a class that has the following code: This is the class I want the forms to refer to for the global variable and other methds.using System;
{
string item = "Map"; public string items(string item){
this.labelItemText.Text = item; return item;}
private void labelItemText_Click(object sender, System.EventArgs e)And for example, in a form I want the score to be displayed in a label when the form is started, so I have done this:
Is this the right way? It says somthing about an overload is needed?
{
this.labelItemText.Text = Information.items();}
Drew TaylorPosted Oct 13, 2006, 4:16 AM
Thanks, that is helpful. I don't understand why I need a switch statement, where would the switch statement go in a form that has buttons etc, would it go after the class declaration?
Reena SajithPosted Oct 12, 2006, 1:28 PM