469,609 Members | 2,043 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Help With Label Refresh

Self Taught here so please bear with me.

I have the labelRestrictSites as private on the MainForm.cs. I then access
the labelRestrictSites.Text thru the public string LabelRestrictSites from
another class. So
when I add labelRestrictSites.refresh code to my class I get an error
because the labelRestrictSites
is private. How would I refresh?

****************************************
mainform.cs
private System.Windows.Forms.Label labelRestrictSites;

public string LabelRestrictSites

{

get { return labelRestrictSites.Text; }

set { labelRestrictSites.Text = value; }

}//end property

********************************************
RestircedSites.cs
private void AddRestrictedSites()
{
foreach(string x in strResSitesList)
{
MainForm frm = (MainForm)MainForm.ActiveForm;

frm.LabelRestrictSites = ((iTotal += 1).ToString());
}
}

Nov 16 '05 #1
4 7890
Yogi_Bear_79,

Can you show the call to refresh? It's not in the sample code that you
posted. Also, what is the error that you are getting? It sounds like a
compile time error, but without seeing the code or the error, it's hard to
provide any insight.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:ad********************@comcast.com...
Self Taught here so please bear with me.

I have the labelRestrictSites as private on the MainForm.cs. I then access
the labelRestrictSites.Text thru the public string LabelRestrictSites from
another class. So
when I add labelRestrictSites.refresh code to my class I get an error
because the labelRestrictSites
is private. How would I refresh?

****************************************
mainform.cs
private System.Windows.Forms.Label labelRestrictSites;

public string LabelRestrictSites

{

get { return labelRestrictSites.Text; }

set { labelRestrictSites.Text = value; }

}//end property

********************************************
RestircedSites.cs
private void AddRestrictedSites()
{
foreach(string x in strResSitesList)
{
MainForm frm = (MainForm)MainForm.ActiveForm;

frm.LabelRestrictSites = ((iTotal += 1).ToString());
}
}

Nov 16 '05 #2
I added the line of code in line below. The compile time error is:

MainForm.labeRestrictedSites is inaccessible due to it's protection level

Which I think I understand. That's why I have a public string to access the
text of this label. But I don't know/understand how to access the refresh
feature now
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Yogi_Bear_79,

Can you show the call to refresh? It's not in the sample code that you posted. Also, what is the error that you are getting? It sounds like a
compile time error, but without seeing the code or the error, it's hard to
provide any insight.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:ad********************@comcast.com...
Self Taught here so please bear with me.

I have the labelRestrictSites as private on the MainForm.cs. I then access the labelRestrictSites.Text thru the public string LabelRestrictSites from another class. So
when I add labelRestrictSites.refresh code to my class I get an error
because the labelRestrictSites
is private. How would I refresh?

****************************************
mainform.cs
private System.Windows.Forms.Label labelRestrictSites;

public string LabelRestrictSites

{

get { return labelRestrictSites.Text; }

set { labelRestrictSites.Text = value; }

}//end property

********************************************
RestircedSites.cs
private void AddRestrictedSites()
{
foreach(string x in strResSitesList)
{
MainForm frm = (MainForm)MainForm.ActiveForm;

frm.LabelRestrictSites = ((iTotal += 1).ToString());
frm.LabelRestrictSites.Refresh();
}
}


Nov 16 '05 #3
Yogi_Bear_79,

So if I understand correctly, you want to invoke a refresh from outside
of the class that is hosting the control. In this case, you would have to
expose either the control itself, and call Refresh on that, or create a
method that will call Refresh on the control for you.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:s9********************@comcast.com...
I added the line of code in line below. The compile time error is:

MainForm.labeRestrictedSites is inaccessible due to it's protection level

Which I think I understand. That's why I have a public string to access
the
text of this label. But I don't know/understand how to access the refresh
feature now
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Yogi_Bear_79,

Can you show the call to refresh? It's not in the sample code that

you
posted. Also, what is the error that you are getting? It sounds like a
compile time error, but without seeing the code or the error, it's hard
to
provide any insight.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:ad********************@comcast.com...
> Self Taught here so please bear with me.
>
> I have the labelRestrictSites as private on the MainForm.cs. I then access > the labelRestrictSites.Text thru the public string LabelRestrictSites from > another class. So
> when I add labelRestrictSites.refresh code to my class I get an error
> because the labelRestrictSites
> is private. How would I refresh?
>
> ****************************************
> mainform.cs
> private System.Windows.Forms.Label labelRestrictSites;
>
> public string LabelRestrictSites
>
> {
>
> get { return labelRestrictSites.Text; }
>
> set { labelRestrictSites.Text = value; }
>
> }//end property
>
> ********************************************
> RestircedSites.cs
> private void AddRestrictedSites()
> {
> foreach(string x in strResSitesList)
> {
> MainForm frm = (MainForm)MainForm.ActiveForm;
>
> frm.LabelRestrictSites = ((iTotal += 1).ToString());
frm.LabelRestrictSites.Refresh();
> }
> }
>
>
>



Nov 16 '05 #4
Nicholas,

Yes this started because as my code updates the labels text value, it
doesn't appear to go up on the form. Meaning it goes from default of Zero,
to the end number in what appears to be an instant. The thinking was if we
invoked a refresh after every loop we could see the number grow. If I
understand you, I can create a method on the form class itself, then call
that method from my other class.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ey**************@TK2MSFTNGP09.phx.gbl...
Yogi_Bear_79,

So if I understand correctly, you want to invoke a refresh from outside of the class that is hosting the control. In this case, you would have to
expose either the control itself, and call Refresh on that, or create a
method that will call Refresh on the control for you.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:s9********************@comcast.com...
I added the line of code in line below. The compile time error is:

MainForm.labeRestrictedSites is inaccessible due to it's protection level
Which I think I understand. That's why I have a public string to access
the
text of this label. But I don't know/understand how to access the refresh feature now
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Yogi_Bear_79,

Can you show the call to refresh? It's not in the sample code that

you
posted. Also, what is the error that you are getting? It sounds like a compile time error, but without seeing the code or the error, it's hard
to
provide any insight.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yogi_Bear_79" <IT*****@spamfree.com> wrote in message
news:ad********************@comcast.com...
> Self Taught here so please bear with me.
>
> I have the labelRestrictSites as private on the MainForm.cs. I then

access
> the labelRestrictSites.Text thru the public string LabelRestrictSites

from
> another class. So
> when I add labelRestrictSites.refresh code to my class I get an error
> because the labelRestrictSites
> is private. How would I refresh?
>
> ****************************************
> mainform.cs
> private System.Windows.Forms.Label labelRestrictSites;
>
> public string LabelRestrictSites
>
> {
>
> get { return labelRestrictSites.Text; }
>
> set { labelRestrictSites.Text = value; }
>
> }//end property
>
> ********************************************
> RestircedSites.cs
> private void AddRestrictedSites()
> {
> foreach(string x in strResSitesList)
> {
> MainForm frm = (MainForm)MainForm.ActiveForm;
>
> frm.LabelRestrictSites = ((iTotal += 1).ToString());
frm.LabelRestrictSites.Refresh();
> }
> }
>
>
>



Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ed Willis | last post: by
2 posts views Thread by Ned Balzer | last post: by
4 posts views Thread by =?Utf-8?B?YmJkb2J1ZGR5?= | last post: by
3 posts views Thread by Mike | last post: by
3 posts views Thread by =?Utf-8?B?cm9kY2hhcg==?= | last post: by
3 posts views Thread by c0elh0 | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.