Hi Aung,
You may need to pass the a reference to the form instance or the
label instance in 'MyUI' to the 'LogicStuff' class.
Alternatively, you can expose events in the 'LogicStuff' class that
is fired when the label needs to be updated. 'MyUI' would then
have to subscribe to these events. When the event is fired,
'MyUI' updates its label.
In the example that you specified, let's assume we adopt the first approach:
class MyUI : Form
{
void PerformBusinessLogic()
{
LogicStuff stuff = new LogicStuff(this);
stuff.DoSomething();
}
void UpdateLabel(String text)
{
lblStatus.Text = text;
}
// ....
}
public class LogicStuff
{
private MyUI _form = null;
public LogicStuff(MyUI form)
{
this._form = form;
}
public void DoSomething()
{
// ....
_form.UpdateLabel("Completed tasks");
}
}
Regards,
Aravind C
"Aung" <au*********@hotmail.com> wrote in message
news:uO**************@TK2MSFTNGP09.phx.gbl...
I have two classes under the same namespace. something like this:
class1
~~~~~
namespace myProject
{
class myUI
{
public System.Windows.Forms.Label lblStatus;
.
.
.
}
}
class2
~~~~
namespace myProject
{
class logicStuff
{
//code to do some business logic
}
}
Question: How can i change the lable value of class1 from class2?
Thank you in advance for your help.
-Aung