Make Label Counter work better?

  • Thread starter Thread starter Yogi_Bear_79
  • Start date Start date
Y

Yogi_Bear_79

I have a for each loop, that currently runs through an array of 11,000+
items. I exerpted the code part below that I have a question on. I thought
this code would update the form label and increment it by one each time the
code passed to the next element in the array. Maybe it just goes to fast,
but it goes from zero (default) to thte final number in what appears to be
one motion.



private void AddRestrictedSites()

{

foreach(string x in strResSitesList)

{

MainForm frm = (MainForm)MainForm.ActiveForm;

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

}



}
 
Try refreshing the control.

frm.LabelRestrictSites = ((iTotal += 1).ToString());
frm.LabelRestrictSites.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. So
when I add your code to my class I can not access the labelRestrictSites
because it 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());
}
}

**********************************************
 
Back
Top