473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

controling UI of a class

I have two classes under the same namespace. something like this:

class1
~~~~~

namespace myProject
{
class myUI
{
public System.Windows.Forms.Label lblStatus;

Nov 15 '05 #1
2 1269
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

Nov 15 '05 #2
Hi Aravind,

Thanks for the help.
I think i will have to follow your second method.

The reason is that "LogicStuff" will be called by 3rd class and i would like
"LogicStuff" to update the Status on "MyUI".
from your example, "MyUI" call "LogicStuff". In my case, this cannot be
done. :(

Is it possible for you to draft some code for your second suggestion?

-Aung

"Aravind C" <ar***********@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Lauren Wilson | last post by:
Hi folks, Can someone point me to some resources on how to control FTP sessions from and Access application with VBA? Many thanks for all help. --LW.
1
by: Tim | last post by:
I need to be able to control drive mapping on a win2000 server with C#. I will need to be able to check for it's existence (think I figured this out) and most importantly create a mapping to a...
1
by: Mohammed Abdel-Razzak | last post by:
Dear sirs I want you to give me link to some articles talking about controling the computer hardware from C#. But what I most need now: How can I open the CDRom from my C# application??? ...
5
by: David C. Allen | last post by:
I have a vb.net app that is controling excel 2000 thru the com interop interface. I have referenced the excel 9.0 library and have cut down the code in the problem subroutine to this: Dim...
6
by: Matthew | last post by:
I am wondering if it is possible to make something like the following work: Public Class myTestSettings Public Property onTop() As Boolean Get Return Form1.CheckBox1.Checked End Get Set(ByVal...
0
by: TY | last post by:
Hi Everyone, I have a multithreading application, a typical Main thread that uses the ThreadPool.QueueUserWorkItem method to add new threads to the Thread POOL. I need a way to control the...
2
by: Beaker | last post by:
I have a user object that I am using in two areas, natively in the application and in a web service. The object is fairly simple, ie class user { private string myFirstName; public string...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
1
by: Phil Galey | last post by:
If you're using XMLSerializer to serialize a class object to XML, is it at all possible to control the order in which the object properties are presented in the XML file?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.