I want to access certain form elements from classes that normally don't have access to them. Allow me to illustrate the problem.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Collections;
namespace MyApp {
public partial class MyApp : Form
{
public MyApp()
{
InitializeComponent();
// Code
}
public void updateLabel(string message)
{
myLabel.Text = message;
}
}
public class NewClass
{
public NewClass()
{
// I want to call updateLabel("My message") here, but 'MyApp.updateLabel("My message");' didn't work even though I made updateLabel public
}
}
}
How do I tackle this issue? I'm relatively new to C#, but I have experience with C, PHP, Java and JavaScript. I'm using Visual C# 2010 Express.