Hi,

Here's what I've got:
Visual Studio 2005
C# Application with form and a label on it
(This is a simplified project ;) )

Here's what I'd like to do:
I want to change text on the label from the method I'll create. Looks simple... If I'll create a button which will change a label's text, it works. But if I want to change it from method I've created on my own, it's impossible... I just don't see any label in my method... Is there some way to access it?

Thanks, Steve

Hi,

void change(string s)
{
  label1.Text = s;
}

private void button1_Click(object sender, System.EventArgs e)
{
  change("Hakan");
}

As you see you have to call your own method from somewhere.

Loren Soth

If you cant see your label, you may have created the new method in a different class as your form. Did you make a new cs file?

Thanks Loren,

I've declared my method as:

[B]public static [/B]void change(string s)
{
  label1.Text = s;
}

and because of that I was unable to use label1 :rolleyes: . I've tried to declare it as void only and it works...

So thanx a lot,
Steve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.