473,586 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1281
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 PerformBusiness Logic()
{
LogicStuff stuff = new LogicStuff(this );
stuff.DoSomethi ng();
}

void UpdateLabel(Str ing text)
{
lblStatus.Text = text;
}

// ....
}
public class LogicStuff
{
private MyUI _form = null;

public LogicStuff(MyUI form)
{
this._form = form;
}

public void DoSomething()
{
// ....
_form.UpdateLab el("Completed tasks");
}
}
Regards,
Aravind C
"Aung" <au*********@ho tmail.com> wrote in message
news:uO******** ******@TK2MSFTN GP09.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******** ********@TK2MSF TNGP11.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 PerformBusiness Logic()
{
LogicStuff stuff = new LogicStuff(this );
stuff.DoSomethi ng();
}

void UpdateLabel(Str ing text)
{
lblStatus.Text = text;
}

// ....
}
public class LogicStuff
{
private MyUI _form = null;

public LogicStuff(MyUI form)
{
this._form = form;
}

public void DoSomething()
{
// ....
_form.UpdateLab el("Completed tasks");
}
}
Regards,
Aravind C
"Aung" <au*********@ho tmail.com> wrote in message
news:uO******** ******@TK2MSFTN GP09.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
25399
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
1710
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 server when necessary. Thanks for any clues you can give me on where to start looking.
1
1380
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??? thanks Mohammed
5
2466
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 objExcelApp As New Excel.Application objExcelApp.Quit() objExcelApp = Nothing The problem is excel is hanging in memory and has to be closed by the...
6
1174
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 Value As Boolean) Form1.CheckBox1.Checked = Value End Set
0
1162
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 threads created by the thread pool because some created threads go indefinilty for a long period of time and I would like to terminate these threads. I...
2
1396
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 FirstName { get; set} ... }
9
2460
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 post event will always execuate after the system is completed... - I want to wrap this functionality in a framework, so I could possibly have 3 or 4...
1
2171
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
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.