コード例 #1
0
		private void GetPeopleButton_Click(object sender, System.EventArgs e)
		{
			OperationControl.GetInstance().Start("Get People", numPeople);
			People people = new People();
			this.peopleList.Items.Clear();

			foreach (PersonInformation person in people.GetPeople(this.numPeople))
			{
				ListViewItem personItem = new ListViewItem(new string[] { person.FullName, person.Employer });
				personItem.ForeColor = Color.FromName("Blue");
				this.peopleList.Items.Add(personItem);
				OperationControl.GetInstance().Increment(1);
			}
			OperationControl.GetInstance().Stop();
			
		}
コード例 #2
0
		private void GetPeopleButton_Click(object sender, System.EventArgs e)
		{
			OperationControl.GetInstance().Start("Get People", numPeople);
			People people = new People();
			this.peopleList.Items.Clear();

			// use BeginUpdate to minimize repainting
			this.peopleList.BeginUpdate();
			foreach (PersonInformation person in people.GetPeople(this.numPeople))
			{
				ListViewItem personItem = new ListViewItem(new string[] { person.FullName, person.Employer });
				
				// use enumerated value instead of literals
				personItem.ForeColor = Color.Blue;
				
				this.peopleList.Items.Add(personItem);
				OperationControl.GetInstance().Increment(1);
			}
			// call EndUpdate to do one repaint
			this.peopleList.EndUpdate();

			OperationControl.GetInstance().Stop();
		}