interface and refresh

T

tshad

I have an interface I am using to get access to some of the objects on my
form: a textbox (Status) and my statusbar (StatusBar). In my class, which
is actually in another class from my form I have the following:

public interface IStatusDisplay
{
string Status { get; set; }
string StatusBar { get; set; }
}

In my class (which is the form), I have:
*****************************************
public partial class FieldSetup : Form, IStatusDisplay

.....

#region IStatusDisplay Members

string IStatusDisplay.Status
{
get
{
return Status.Text;
}
set
{
Status.Text = value;
}
}

string IStatusDisplay.StatusBar
{
get
{
return toolStripStatusLabel1.Text;
}
set
{
toolStripStatusLabel1.Text = value;
}
}
********************************************

In my form code I pass: this. In my other classes, I use:

void function(IStatusDisplay display)
{
display.StatusBar = "This is a test";
}

This works fine, except it won't return until you return from the function
( I am not threading this, at this point).

But in the form itself, I can do a this.refresh - but how do I change my
code so I can do a refresh from my other classes?

Thanks,

Tom
 
T

tshad

I figured it out.

I can just put this.refresh in the "set" portion of the property - or just
create a method in the interface called refresh() and in that method do a
this.refresh().

Tom
 
T

tshad

Well, it almost works.

I have the function set as:

*****************************************
public partial class FieldSetup : Form, IStatusDisplay

.....

#region IStatusDisplay Members

string IStatusDisplay.Status
{
get
{
return Status.Text;
}
set
{
Status.Text = value;
}
}

string IStatusDisplay.StatusBar
{
get
{
return toolStripStatusLabel1.Text;
}
set
{
toolStripStatusLabel1.Text = value;
this.Refresh();
}
}
********************************************

It works most of the time. But then it stops refreshing the screen - no
matter how many time it does:

display.StatusBar = "Now Processing... " + xmlFile;

Which does a this.Refresh() after setting the value.

Not sure why it quits working. I know it is doing it as I step through it
and see it hit the this.Refresh().

Tom
 
K

Ken Foskey

That said, if you need to call Refresh() to get your UI to redraw, then
your design is wrong anyway. You should just call Invalidate() and let
the repainting happen normally.

What is the difference?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top