Home > Articles > Programming > User Interface (UI)

This chapter is from the book

Programming the ProgressBar Control

The ProgressBar control gives your users a graphical representation of how an operation is progressing. This is useful when your application needs to perform a very time-consuming operation and you do not want the user to think the application has crashed or entered an endless loop.

The ProgressBar control is controlled by three Int32 properties: Minimum, Maximum, and Value. The Minimum and Maximum values define the minimum and maximum values of the ProgressBar control. The Value property defines the ProgressBar control's current value. The ProgressBar will be filled in from left to right as the Value property moves increasingly away from the Minimum value toward the Maximum value. The ProgressBar control is empty when the Value property is equal to the Minimum property. And once the Value property is equal to the Maximum value, the ProgressBar will be full. Immediately after the Value property is changed, the ProgressBar control will be repainted to reflect the new value.

Figures 3.11 and 3.12 show the BombSquad.exe game running in the Pocket PC 2002 emulator. The BombSquad game is a simple game that gives you a set amount of time to diffuse a dangerous bomb by clicking the Diffuse button before the ProgressBar control is filled. The Diffuse button's location continuously changes while the game is being played. Figure 3.11 shows the results of a successful diffusing, whereas Figure 3.12 shows what happens when you cannot diffuse the bomb in time. You will find the code for the BombSquad game in the source code for this book.

Figure 3.11Figure 3.11 You win the BombSquad game by diffusing the bomb before the progress bar fills up.

Figure 3.12Figure 3.12 You lose the BombSquad game by failing to diffuse the bomb before the progress bar fills up.

  • + Share This
  • 🔖 Save To Your Account