PC Review


Reply
Thread Tools Rate Thread

Accessing objects between forms - C#, CF, WM 2003 SE

 
 
=?Utf-8?B?Sm9obiBCb3Jlbg==?=
Guest
Posts: n/a
 
      3rd Sep 2004
I'm writing an application where I have incoming data via TCP into a Static
global routine. From that routine, I'm wanting to display the error message
on a form.

Now I have tried many variations of getting access to the object ( a message
label), but basically, as soon as it tries to assign the message label.text,
the program just stops in that code.

I'm using VS 2003 - C# - Writing for WM 2003 SE

1. I'm calling this from Public Static routine in a different namespace.
2. FSignon is the name of the form.
3. FSignon_int is a public reference to the form:
public static FSignon FSignon_int;
4. The form is displaying.
5. I'm then trying to assign the message label as follows:

public static void ipInMsg(string mytext);

FSignon.FSignon_int.MsgLabel.Text=mytext;
(debugging ends on this line)

So, how is one normally suppose to be able to assign or change values of
objects on other forms? I was thinking about window messaging .. but not
sure on the impact with CF or some Invoke statement?

Just needs some direction here.

Thanks
John



 
Reply With Quote
 
 
 
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      3rd Sep 2004
If the event is coming in on a separate thread (not clear from your post)
then you must use Invoke to access any UI element.

-Chris


"John Boren" <John (E-Mail Removed)> wrote in message
news:C62A1F49-0A88-4383-9168-(E-Mail Removed)...
> I'm writing an application where I have incoming data via TCP into a

Static
> global routine. From that routine, I'm wanting to display the error

message
> on a form.
>
> Now I have tried many variations of getting access to the object ( a

message
> label), but basically, as soon as it tries to assign the message

label.text,
> the program just stops in that code.
>
> I'm using VS 2003 - C# - Writing for WM 2003 SE
>
> 1. I'm calling this from Public Static routine in a different namespace.
> 2. FSignon is the name of the form.
> 3. FSignon_int is a public reference to the form:
> public static FSignon FSignon_int;
> 4. The form is displaying.
> 5. I'm then trying to assign the message label as follows:
>
> public static void ipInMsg(string mytext);
>
> FSignon.FSignon_int.MsgLabel.Text=mytext;
> (debugging ends on this line)
>
> So, how is one normally suppose to be able to assign or change values of
> objects on other forms? I was thinking about window messaging .. but not
> sure on the impact with CF or some Invoke statement?
>
> Just needs some direction here.
>
> Thanks
> John
>
>
>



 
Reply With Quote
 
=?Utf-8?B?Sm9obiBCb3Jlbg==?=
Guest
Posts: n/a
 
      7th Sep 2004
I believe I am dealing with a basic mis-understanding of getting access to
objects from different classes.

1. I do have a separate thread (an event) that is taking inbound data.
2. I am parsing that data and I want to put that information into a Label
object on potentially two different forms.

So, here is the path I have:

1. Data comes in via an event in a class named 'Globals'.
2. In a "STATIC METHOD" - the event, I then decide which form should
receive the information.
3. I am then attempting to call that form's label to put the message I
received so the user can see it. (In this case, it could be either the form
named "FMain" in class "main" or in a form named "FSignon" in the class
"signon".

Now, how is this supposed to work from a static event? I've tried creating
a reference to the form's form by doing a:
===
public class FSignon: System.Windows.Forms.Form
{
public static FSignon FSignon_int;

(I saw this in another posting).
=====
But, when I tried to do this, the application stops processing:
FSignon.FSignon_int.msglabel.text="Error";

=================================
And, I also tried doing an invoke...but how are you to invoke an object
outside the class?

Thanks
John
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing OLE objects =?Utf-8?B?TWFydGluIFdoaXRlc2lkZQ==?= Microsoft Access VBA Modules 2 25th Jan 2006 11:41 AM
Accessing MC++ objects from C++ dll Daniel =?iso-8859-1?Q?Lidstr=F6m?= Microsoft C# .NET 1 4th Nov 2004 07:52 PM
Creating forms as objects and accessing their members in VB Geoff Callaghan Microsoft Dot NET Compact Framework 1 27th Oct 2004 11:10 PM
accessing NET(C#) objects from VB6 =?Utf-8?B?QWxleCBLLg==?= Microsoft C# .NET 0 17th Sep 2004 06:57 PM
Sharing objects across forms and other objects Evan Microsoft C# .NET 2 10th Dec 2003 03:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:04 PM.