Updating form controls from another class?

  • Thread starter Thread starter ORC
  • Start date Start date
O

ORC

Hi,

I have an application that has 7 forms. I would like to update the controls
on the forms from a single class. How should I do that if possible? The
reason for this is that my application is made for both full- and compact
framework and all the code except the forms is the same.

Thanks
Ole
 
Ole,

I would think that you just pass a reference to each of the forms to the
class. Unless you derive all the forms from a base class which helps to
define the user interface elements in a more coherent manner, you will have
to access the controls through the Controls collection.

Or is there something I'm missing?
 
I am having the same sort of issue:

I have set up a class that handles my TcpClient communications. I pass it a
reference to a Label. I then want to dynamically update this Label with
status information. Nothing happens. I have tried all sorts of calls to cause
the Label to “redraw†to no avail. Here is a little snippet:

char[] seps = {' '};
string[] values = response.Split(seps);
retval.Add(values[0]);
extLbl.Select();
extLbl.Focus();
extLbl.Text=values[0];
extLbl.Update();
extLbl.BringToFront();
newsgroupForm.Update();
bval=extLbl.InvokeRequired;
bval=extLbl.IsAccessible;
extLbl.Invalidate();
extLbl.Refresh();


Needless to say, I have thrown everything in except the kitchen sink, and
the Label still refuses to update.

So what do I do now???

Nicholas Paldino said:
Ole,

I would think that you just pass a reference to each of the forms to the
class. Unless you derive all the forms from a base class which helps to
define the user interface elements in a more coherent manner, you will have
to access the controls through the Controls collection.

Or is there something I'm missing?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

ORC said:
Hi,

I have an application that has 7 forms. I would like to update the
controls
on the forms from a single class. How should I do that if possible? The
reason for this is that my application is made for both full- and compact
framework and all the code except the forms is the same.

Thanks
Ole
 
Back
Top